}
public Object unmarshal(final HierarchicalStreamReader reader, final UnmarshallingContext context) {
final Class type = context.getRequiredType();
try {
final Externalizable externalizable = (Externalizable) type.newInstance();
CustomObjectInputStream.StreamCallback callback = new CustomObjectInputStream.StreamCallback() {
public Object readFromStream() {
reader.moveDown();
Class type = HierarchicalStreams.readClassType(reader, mapper);
Object streamItem = context.convertAnother(externalizable, type);
reader.moveUp();
return streamItem;
}
public Map readFieldsFromStream() {
throw new UnsupportedOperationException();
}
public void defaultReadObject() {
throw new UnsupportedOperationException();
}
public void registerValidation(ObjectInputValidation validation, int priority) throws NotActiveException {
throw new NotActiveException("stream inactive");
}
public void close() {
throw new UnsupportedOperationException("Objects are not allowed to call ObjectInput.close() from readExternal()");
}
};
CustomObjectInputStream objectInput = CustomObjectInputStream.getInstance(context, callback);
externalizable.readExternal(objectInput);
objectInput.popCallback();
return externalizable;
} catch (InstantiationException e) {
throw new ConversionException("Cannot construct " + type.getClass(), e);
} catch (IllegalAccessException e) {