{
ByteArrayInputStream bais = new ByteArrayInputStream(state);
bais.mark(1024);
short version = 0;
MarshalledValueInputStream in = null;
try {
in = new MarshalledValueInputStream(bais);
}
catch (IOException e) {
// No short at the head of the stream means version 123
version = RV_123;
}
try {
if (in != null) {
try {
version = in.readShort();
}
catch (IOException io) {
// No short at the head of the stream means version 123
version = RV_123;
}
}
// Compiler won't let me use a switch
// Test 1.2.4 and 1.2.4.SP1 first as these are actually lower numbers
// than 1.2.3 since their shorts used a different algorithm
if (version == RV_124)
return new StateTransferIntegrator_124(in, targetFqn, cache);
else if (version == RV_124SP1)
return new StateTransferIntegrator_1241(state, targetFqn, cache);
else if (version <= RV_123 && version > 0) // <= 0 is actually a version > 15.31.63
return new StateTransferIntegrator_123(state, targetFqn, cache);
else if (version < RV_140 && version > 0) // <= 0 is actually a version > 15.31.63
return new StateTransferIntegrator_1241(state, targetFqn, cache);
else
return new StateTransferIntegrator_140(state, targetFqn, cache); // current default
}
finally {
try {
if (in != null) in.close();
}
catch (IOException io) {}
}
}