case ID_ARRAY:
final String typeArray = input.readString();
if(input.readFieldNumber(schema) != ID_ARRAY_LEN)
throw new ProtostuffException("Corrupt input.");
final int len = input.readUInt32();
if(input.readFieldNumber(schema) != ID_ARRAY_DIMENSION)
throw new ProtostuffException("Corrupt input.");
final int dimensions = input.readUInt32();
final ArrayWrapper arrayWrapper = newArrayWrapper(typeArray, len,
dimensions);
if(input instanceof GraphInput)
{
// update the actual reference.
((GraphInput)input).updateLast(arrayWrapper.array, owner);
}
COLLECTION_SCHEMA.mergeFrom(input, arrayWrapper);
return arrayWrapper.array;
case ID_OBJECT:
if(input.readUInt32() != 0)
throw new ProtostuffException("Corrupt input.");
value = new Object();
break;
case ID_ENUM:
final String typeEnum = input.readString();
final EnumIO<?> eio = EnumIO.get(typeEnum,
AUTO_LOAD_POLYMORPHIC_CLASSES);
if(eio == null)
throw new ProtostuffException("Unknown enum class: " + typeEnum);
if(input.readFieldNumber(schema) != ID_ENUM_VALUE)
throw new ProtostuffException("Corrupt input.");
value = eio.readFrom(input);
break;
case ID_COLLECTION:
final String collectionType = input.readString();
if(collectionType.indexOf('.') != -1)
{
// EnumSet
final Collection<?> c = EnumIO.get(collectionType, true).newEnumSet();
if(input instanceof GraphInput)
{
// update the actual reference.
((GraphInput)input).updateLast(c, owner);
}
COLLECTION_SCHEMA.mergeFrom(input, (Collection<Object>)c);
return c;
}
final Collection<Object> collection =
CollectionSchema.MessageFactories.getFactory(
collectionType).newMessage();
if(input instanceof GraphInput)
{
// update the actual reference.
((GraphInput)input).updateLast(collection, owner);
}
COLLECTION_SCHEMA.mergeFrom(input, collection);
return collection;
case ID_MAP:
final String mapType = input.readString();
if(mapType.indexOf('.') != -1)
{
// EnumMap
final Map<?,Object> m = EnumIO.get(mapType, true).newEnumMap();
if(input instanceof GraphInput)
{
// update the actual reference.
((GraphInput)input).updateLast(m, owner);
}
MAP_SCHEMA.mergeFrom(input, (Map<Object, Object>)m);
return m;
}
final Map<Object,Object> map =
MapSchema.MessageFactories.getFactory(mapType).newMessage();
if(input instanceof GraphInput)
{
// update the actual reference.
((GraphInput)input).updateLast(map, owner);
}
MAP_SCHEMA.mergeFrom(input, map);
return map;
case ID_POJO:
final String typePojo = input.readString();
final HasSchema<Object> wrapper = RuntimeSchema.getSchemaWrapper(
typePojo, AUTO_LOAD_POLYMORPHIC_CLASSES);
if(wrapper == null)
throw new ProtostuffException("Unknown pojo class: " + typePojo);
final Schema<Object> derivedSchema = wrapper.getSchema();
final Object pojo = derivedSchema.newMessage();
if(input instanceof GraphInput)
{
// update the actual reference.
((GraphInput)input).updateLast(pojo, owner);
}
derivedSchema.mergeFrom(input, pojo);
return pojo;
default:
throw new ProtostuffException("Corrupt input. Unknown field number: " + number);
}
if(input instanceof GraphInput)
{
// update the actual reference.
((GraphInput)input).updateLast(value, owner);
}
if(input.readFieldNumber(schema) != 0)
throw new ProtostuffException("Corrupt input.");
return value;
}