loc += 4;
final BinaryInputCapsule cap = new BinaryInputCapsule(this, bco);
cap.setContent(_dataArray, loc, loc + dataLength);
final Savable out;
try {
@SuppressWarnings("unchecked")
final Class<? extends Savable> clazz = (Class<? extends Savable>) Class.forName(bco._className);
final SavableFactory ann = clazz.getAnnotation(SavableFactory.class);
if (ann == null) {
out = clazz.newInstance();
} else {
out = (Savable) clazz.getMethod(ann.factoryMethod(), (Class<?>[]) null).invoke(null,
(Object[]) null);
}
} catch (final InstantiationException e) {
logger.logp(Level.SEVERE, this.getClass().toString(), "readObject(int)",
"Could not access constructor of class '" + bco._className + "'! \n"
+ "Some types may require the annotation SavableFactory. Please double check.", e);
throw new Ardor3dException(e);
} catch (final NoSuchMethodException e) {
logger
.logp(
Level.SEVERE,
this.getClass().toString(),
"readObject(int)",
e.getMessage()
+ " \n"
+ "Method specified in annotation does not appear to exist or has an invalid method signature.",
e);
throw new Ardor3dException(e);
}
_capsuleTable.put(out, cap);
_contentTable.put(id, out);
out.read(_capsuleTable.get(out));
_capsuleTable.remove(out);
return out;