@Override public String getFieldName(int number) { return ObjectSchema.name(number); }
@Override public int getFieldNumber(String name) { return ObjectSchema.number(name); }
@Override @SuppressWarnings("unchecked") public void mergeFrom(Input input, Object owner) throws IOException { if (PMapWrapper.class == owner.getClass()) { // called from ENTRY_SCHEMA ((PMapWrapper) owner).setValue(ObjectSchema.readObjectFrom( input, this, owner, IdStrategy.this)); } else { // called from COLLECTION_SCHEMA ((Collection<Object>) owner).add(ObjectSchema.readObjectFrom( input, this, owner, IdStrategy.this)); } }
@Override public void mergeFrom(Input input, Object owner) throws IOException { setValue(readObjectFrom(input, this, owner, strategy), owner); }
@Override public void writeTo(Output output, Object message) throws IOException { ObjectSchema.writeObjectTo(output, message, this, IdStrategy.this); } };
break; case ID_ARRAY: transferArray(pipe, input, output, number, pipeSchema, false, strategy); return; case ID_OBJECT: break; case ID_ARRAY_MAPPED: transferArray(pipe, input, output, number, pipeSchema, true, strategy); return; case ID_CLASS: transferClass(pipe, input, output, number, pipeSchema, false, false, strategy); break; case ID_CLASS_MAPPED: transferClass(pipe, input, output, number, pipeSchema, true, false, strategy); break; case ID_CLASS_ARRAY: transferClass(pipe, input, output, number, pipeSchema, false, true, strategy); break; case ID_CLASS_ARRAY_MAPPED: transferClass(pipe, input, output, number, pipeSchema, true, true, strategy); break;
final ArrayWrapper arrayWrapper = newArrayWrapper(input, schema, false, strategy); final ArrayWrapper mArrayWrapper = newArrayWrapper(input, schema, true, strategy); break; case ID_CLASS_ARRAY: value = getArrayClass(input, schema, strategy.resolveClassFrom(input, false, true)); break; case ID_CLASS_ARRAY_MAPPED: value = getArrayClass(input, schema, strategy.resolveClassFrom(input, true, true)); break;
static void transferObject(Pipe.Schema<Object> pipeSchema, Pipe pipe, Input input, Output output, IdStrategy strategy) throws IOException { final int number = input.readFieldNumber(pipeSchema.wrappedSchema); switch (number) { case ID_ARRAY: ObjectSchema.transferArray(pipe, input, output, number, pipeSchema, false, strategy); return; case ID_ARRAY_MAPPED: ObjectSchema.transferArray(pipe, input, output, number, pipeSchema, true, strategy); return; default: throw new ProtostuffException("Corrupt input."); } }
static void transferObject(Pipe.Schema<Object> pipeSchema, Pipe pipe, Input input, Output output, IdStrategy strategy) throws IOException { final int number = input.readFieldNumber(pipeSchema.wrappedSchema); switch (number) { case ID_CLASS: ObjectSchema.transferClass(pipe, input, output, number, pipeSchema, false, false, strategy); break; case ID_CLASS_MAPPED: ObjectSchema.transferClass(pipe, input, output, number, pipeSchema, true, false, strategy); break; case ID_CLASS_ARRAY: ObjectSchema.transferClass(pipe, input, output, number, pipeSchema, false, true, strategy); break; case ID_CLASS_ARRAY_MAPPED: ObjectSchema.transferClass(pipe, input, output, number, pipeSchema, true, true, strategy); break; default: throw new ProtostuffException("Corrupt input."); } if (0 != input.readFieldNumber(pipeSchema.wrappedSchema)) throw new ProtostuffException("Corrupt input."); }
static Object readObjectFrom(Input input, Schema<?> schema, Object owner, IdStrategy strategy) throws IOException { final int number = input.readFieldNumber(schema); final boolean mapped; switch (number) { case ID_ARRAY: mapped = false; break; case ID_ARRAY_MAPPED: mapped = true; break; default: throw new ProtostuffException("Corrupt input."); } final ArrayWrapper mArrayWrapper = ObjectSchema.newArrayWrapper(input, schema, mapped, strategy); if (input instanceof GraphInput) { // update the actual reference. ((GraphInput) input).updateLast(mArrayWrapper.array, owner); } strategy.COLLECTION_SCHEMA.mergeFrom(input, mArrayWrapper); return mArrayWrapper.array; }
value = ObjectSchema.getArrayClass(input, schema, strategy.resolveClassFrom(input, false, true)); break; value = ObjectSchema.getArrayClass(input, schema, strategy.resolveClassFrom(input, true, true)); break;
@Override public void writeTo(Output output, Object message) throws IOException { ObjectSchema.writeObjectTo(output, message, this, IdStrategy.this); } };
@Override public void mergeFrom(Input input, Object owner) throws IOException { setValue(readObjectFrom(input, this, owner, strategy), owner); }
break; case ID_ARRAY: transferArray(pipe, input, output, number, pipeSchema, false, strategy); return; case ID_OBJECT: break; case ID_ARRAY_MAPPED: transferArray(pipe, input, output, number, pipeSchema, true, strategy); return; case ID_CLASS: transferClass(pipe, input, output, number, pipeSchema, false, false, strategy); break; case ID_CLASS_MAPPED: transferClass(pipe, input, output, number, pipeSchema, true, false, strategy); break; case ID_CLASS_ARRAY: transferClass(pipe, input, output, number, pipeSchema, false, true, strategy); break; case ID_CLASS_ARRAY_MAPPED: transferClass(pipe, input, output, number, pipeSchema, true, true, strategy); break;
final ArrayWrapper arrayWrapper = newArrayWrapper(input, schema, false, strategy); final ArrayWrapper mArrayWrapper = newArrayWrapper(input, schema, true, strategy); break; case ID_CLASS_ARRAY: value = getArrayClass(input, schema, strategy.resolveClassFrom(input, false, true)); break; case ID_CLASS_ARRAY_MAPPED: value = getArrayClass(input, schema, strategy.resolveClassFrom(input, true, true)); break;
static void transferObject(Pipe.Schema<Object> pipeSchema, Pipe pipe, Input input, Output output, IdStrategy strategy) throws IOException { final int number = input.readFieldNumber(pipeSchema.wrappedSchema); switch (number) { case ID_ARRAY: ObjectSchema.transferArray(pipe, input, output, number, pipeSchema, false, strategy); return; case ID_ARRAY_MAPPED: ObjectSchema.transferArray(pipe, input, output, number, pipeSchema, true, strategy); return; default: throw new ProtostuffException("Corrupt input."); } }
static void transferObject(Pipe.Schema<Object> pipeSchema, Pipe pipe, Input input, Output output, IdStrategy strategy) throws IOException { final int number = input.readFieldNumber(pipeSchema.wrappedSchema); switch (number) { case ID_CLASS: ObjectSchema.transferClass(pipe, input, output, number, pipeSchema, false, false, strategy); break; case ID_CLASS_MAPPED: ObjectSchema.transferClass(pipe, input, output, number, pipeSchema, true, false, strategy); break; case ID_CLASS_ARRAY: ObjectSchema.transferClass(pipe, input, output, number, pipeSchema, false, true, strategy); break; case ID_CLASS_ARRAY_MAPPED: ObjectSchema.transferClass(pipe, input, output, number, pipeSchema, true, true, strategy); break; default: throw new ProtostuffException("Corrupt input."); } if (0 != input.readFieldNumber(pipeSchema.wrappedSchema)) throw new ProtostuffException("Corrupt input."); }
static Object readObjectFrom(Input input, Schema<?> schema, Object owner, IdStrategy strategy) throws IOException { final int number = input.readFieldNumber(schema); final boolean mapped; switch (number) { case ID_ARRAY: mapped = false; break; case ID_ARRAY_MAPPED: mapped = true; break; default: throw new ProtostuffException("Corrupt input."); } final ArrayWrapper mArrayWrapper = ObjectSchema.newArrayWrapper(input, schema, mapped, strategy); if (input instanceof GraphInput) { // update the actual reference. ((GraphInput) input).updateLast(mArrayWrapper.array, owner); } strategy.COLLECTION_SCHEMA.mergeFrom(input, mArrayWrapper); return mArrayWrapper.array; }
value = ObjectSchema.getArrayClass(input, schema, strategy.resolveClassFrom(input, false, true)); break; value = ObjectSchema.getArrayClass(input, schema, strategy.resolveClassFrom(input, true, true)); break;
@Override public String getFieldName(int number) { return name(number); }