io.protostuff.ProtostuffException Java Examples
The following examples show how to use
io.protostuff.ProtostuffException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ArraySchemas.java From protostuff with Apache License 2.0 | 6 votes |
protected Object readPrimitiveFrom(Input input, Object owner, int len) throws IOException { int[] array = new int[len]; if (input instanceof GraphInput) { // update the actual reference. ((GraphInput) input).updateLast(array, owner); } for (int i = 0; i < len; i++) { if (ID_ARRAY_DATA != input.readFieldNumber(this)) throw new ProtostuffException("Corrupt input."); array[i] = input.readInt32(); } if (0 != input.readFieldNumber(this)) throw new ProtostuffException("Corrupt input."); return array; }
Example #2
Source File: ObjectSchema.java From protostuff with Apache License 2.0 | 6 votes |
static Class<?> getArrayClass(Input input, Schema<?> schema, final Class<?> componentType) throws IOException { if (input.readFieldNumber(schema) != ID_ARRAY_DIMENSION) throw new ProtostuffException("Corrupt input."); final int dimensions = input.readUInt32(); // TODO is there another way (reflection) to obtain an array class? if (dimensions == 1) return Array.newInstance(componentType, 0).getClass(); final int[] arg = new int[dimensions]; arg[0] = 0; return Array.newInstance(componentType, arg).getClass(); }
Example #3
Source File: ArraySchemas.java From protostuff with Apache License 2.0 | 6 votes |
protected Object readPrimitiveFrom(Input input, Object owner, int len) throws IOException { double[] array = new double[len]; if (input instanceof GraphInput) { // update the actual reference. ((GraphInput) input).updateLast(array, owner); } for (int i = 0; i < len; i++) { if (ID_ARRAY_DATA != input.readFieldNumber(this)) throw new ProtostuffException("Corrupt input."); array[i] = input.readDouble(); } if (0 != input.readFieldNumber(this)) throw new ProtostuffException("Corrupt input."); return array; }
Example #4
Source File: ObjectSchema.java From protostuff with Apache License 2.0 | 6 votes |
static void transferArray(Pipe pipe, Input input, Output output, int number, Pipe.Schema<?> pipeSchema, boolean mapped, IdStrategy strategy) throws IOException { strategy.transferArrayId(input, output, number, mapped); if (input.readFieldNumber(pipeSchema.wrappedSchema) != ID_ARRAY_LEN) throw new ProtostuffException("Corrupt input."); output.writeUInt32(ID_ARRAY_LEN, input.readUInt32(), false); if (input.readFieldNumber(pipeSchema.wrappedSchema) != ID_ARRAY_DIMENSION) throw new ProtostuffException("Corrupt input."); output.writeUInt32(ID_ARRAY_DIMENSION, input.readUInt32(), false); if (output instanceof StatefulOutput) { // update using the derived schema. ((StatefulOutput) output).updateLast(strategy.ARRAY_PIPE_SCHEMA, pipeSchema); } Pipe.transferDirect(strategy.ARRAY_PIPE_SCHEMA, pipe, input, output); }
Example #5
Source File: ArraySchemas.java From protostuff with Apache License 2.0 | 6 votes |
protected Object readPrimitiveFrom(Input input, Object owner, int len) throws IOException { float[] array = new float[len]; if (input instanceof GraphInput) { // update the actual reference. ((GraphInput) input).updateLast(array, owner); } for (int i = 0; i < len; i++) { if (ID_ARRAY_DATA != input.readFieldNumber(this)) throw new ProtostuffException("Corrupt input."); array[i] = input.readFloat(); } if (0 != input.readFieldNumber(this)) throw new ProtostuffException("Corrupt input."); return array; }
Example #6
Source File: PolymorphicEnumSchema.java From protostuff with Apache License 2.0 | 6 votes |
static Object readObjectFrom(Input input, Schema<?> schema, Object owner, IdStrategy strategy) throws IOException { if (ID_ENUM != input.readFieldNumber(schema)) throw new ProtostuffException("Corrupt input."); final EnumIO<?> eio = strategy.resolveEnumFrom(input); if (ID_ENUM_VALUE != input.readFieldNumber(schema)) throw new ProtostuffException("Corrupt input."); final Object value = eio.readFrom(input); if (input instanceof GraphInput) { // update the actual reference. ((GraphInput) input).updateLast(value, owner); } if (0 != input.readFieldNumber(schema)) throw new ProtostuffException("Corrupt input."); return value; }
Example #7
Source File: PolymorphicEnumSchema.java From protostuff with Apache License 2.0 | 6 votes |
static void transferObject(Pipe.Schema<Object> pipeSchema, Pipe pipe, Input input, Output output, IdStrategy strategy) throws IOException { if (ID_ENUM != input.readFieldNumber(pipeSchema.wrappedSchema)) throw new ProtostuffException("Corrupt input."); strategy.transferEnumId(input, output, ID_ENUM); if (ID_ENUM_VALUE != input.readFieldNumber(pipeSchema.wrappedSchema)) throw new ProtostuffException("Corrupt input."); EnumIO.transfer(pipe, input, output, 1, false, strategy); if (0 != input.readFieldNumber(pipeSchema.wrappedSchema)) throw new ProtostuffException("Corrupt input."); }
Example #8
Source File: ArraySchemas.java From protostuff with Apache License 2.0 | 6 votes |
protected Object readPrimitiveFrom(Input input, Object owner, int len) throws IOException { long[] array = new long[len]; if (input instanceof GraphInput) { // update the actual reference. ((GraphInput) input).updateLast(array, owner); } for (int i = 0; i < len; i++) { if (ID_ARRAY_DATA != input.readFieldNumber(this)) throw new ProtostuffException("Corrupt input."); array[i] = input.readInt64(); } if (0 != input.readFieldNumber(this)) throw new ProtostuffException("Corrupt input."); return array; }
Example #9
Source File: ObjectSchema.java From protostuff with Apache License 2.0 | 6 votes |
static ArrayWrapper newArrayWrapper(Input input, Schema<?> schema, boolean mapped, IdStrategy strategy) throws IOException { final Class<?> componentType = strategy.resolveArrayComponentTypeFrom( input, mapped); 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(); if (dimensions == 1) return new ArrayWrapper(Array.newInstance(componentType, len)); final int[] arg = new int[dimensions]; arg[0] = len; return new ArrayWrapper(Array.newInstance(componentType, arg)); }
Example #10
Source File: ArraySchema.java From protostuff with Apache License 2.0 | 6 votes |
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."); } }
Example #11
Source File: DefaultIdStrategy.java From protostuff with Apache License 2.0 | 6 votes |
@Override protected <T> HasSchema<T> transferPojoId(Input input, Output output, int fieldNumber) throws IOException { final String className = input.readString(); final HasSchema<T> wrapper = getSchemaWrapper(className, 0 != (AUTO_LOAD_POLYMORPHIC_CLASSES & flags)); if (wrapper == null) { throw new ProtostuffException("polymorphic pojo not registered: " + className); } output.writeString(fieldNumber, className, false); return wrapper; }
Example #12
Source File: ArraySchemas.java From protostuff with Apache License 2.0 | 6 votes |
protected Object readPrimitiveFrom(Input input, Object owner, int len) throws IOException { short[] array = new short[len]; if (input instanceof GraphInput) { // update the actual reference. ((GraphInput) input).updateLast(array, owner); } for (int i = 0; i < len; i++) { if (ID_ARRAY_DATA != input.readFieldNumber(this)) throw new ProtostuffException("Corrupt input."); array[i] = (short) input.readUInt32(); } if (0 != input.readFieldNumber(this)) throw new ProtostuffException("Corrupt input."); return array; }
Example #13
Source File: DerivativeSchema.java From protostuff with Apache License 2.0 | 6 votes |
@Override public void transfer(Pipe pipe, Input input, Output output) throws IOException { final int first = input.readFieldNumber(DerivativeSchema.this); if (first != ID_POJO) throw new ProtostuffException("order not preserved."); final Pipe.Schema<Object> pipeSchema = strategy.transferPojoId( input, output, ID_POJO).getPipeSchema(); if (output instanceof StatefulOutput) { // update using the derived schema. ((StatefulOutput) output).updateLast(pipeSchema, this); } Pipe.transferDirect(pipeSchema, pipe, input, output); }
Example #14
Source File: ArraySchemas.java From protostuff with Apache License 2.0 | 6 votes |
protected Object readPrimitiveFrom(Input input, Object owner, int len) throws IOException { char[] array = new char[len]; if (input instanceof GraphInput) { // update the actual reference. ((GraphInput) input).updateLast(array, owner); } for (int i = 0; i < len; i++) { if (ID_ARRAY_DATA != input.readFieldNumber(this)) throw new ProtostuffException("Corrupt input."); array[i] = (char) input.readUInt32(); } if (0 != input.readFieldNumber(this)) throw new ProtostuffException("Corrupt input."); return array; }
Example #15
Source File: ArraySchemas.java From protostuff with Apache License 2.0 | 6 votes |
protected Object readPrimitiveFrom(Input input, Object owner, int len) throws IOException { boolean[] array = new boolean[len]; if (input instanceof GraphInput) { // update the actual reference. ((GraphInput) input).updateLast(array, owner); } for (int i = 0; i < len; i++) { if (ID_ARRAY_DATA != input.readFieldNumber(this)) throw new ProtostuffException("Corrupt input."); array[i] = input.readBool(); } if (0 != input.readFieldNumber(this)) throw new ProtostuffException("Corrupt input."); return array; }
Example #16
Source File: ArraySchemas.java From protostuff with Apache License 2.0 | 5 votes |
@Override public Object readFrom(Input input, Object owner) throws IOException { if (ID_ARRAY_LEN != input.readFieldNumber(this)) throw new ProtostuffException("Corrupt input."); final int len = input.readInt32(); Object[] array = (Object[])Array.newInstance(eio.enumClass, len); if (input instanceof GraphInput) { // update the actual reference. ((GraphInput) input).updateLast(array, owner); } for (int i = 0; i < len;) { switch (input.readFieldNumber(this)) { case ID_ARRAY_DATA: array[i++] = eio.readFrom(input); break; case ID_ARRAY_NULLCOUNT: i += input.readUInt32(); break; default: throw new ProtostuffException("Corrupt input."); } } if (0 != input.readFieldNumber(this)) throw new ProtostuffException("Corrupt input."); return array; }
Example #17
Source File: PolymorphicPojoSchema.java From protostuff with Apache License 2.0 | 5 votes |
static void transferObject(Pipe.Schema<Object> pipeSchema, Pipe pipe, Input input, Output output, IdStrategy strategy) throws IOException { final int number = input.readFieldNumber(pipeSchema.wrappedSchema); if (number != ID_POJO) throw new ProtostuffException("Corrupt input."); transferObject(pipeSchema, pipe, input, output, strategy, number); }
Example #18
Source File: PolymorphicPojoSchema.java From protostuff with Apache License 2.0 | 5 votes |
static Object readObjectFrom(Input input, Schema<?> schema, Object owner, IdStrategy strategy) throws IOException { final int number = input.readFieldNumber(schema); if (number != ID_POJO) throw new ProtostuffException("Corrupt input."); return readObjectFrom(input, schema, owner, strategy, number); }
Example #19
Source File: ArraySchemas.java From protostuff with Apache License 2.0 | 5 votes |
@Override public Object readFrom(Input input, Object owner) throws IOException { if (ID_ARRAY_LEN != input.readFieldNumber(this)) throw new ProtostuffException("Corrupt input."); final int len = input.readInt32(); Object[] array = (Object[])Array.newInstance(hs.getSchema().typeClass(), len); if (input instanceof GraphInput) { // update the actual reference. ((GraphInput) input).updateLast(array, owner); } for (int i = 0; i < len;) { switch (input.readFieldNumber(this)) { case ID_ARRAY_DATA: array[i++] = input.mergeObject(null, hs.getSchema()); break; case ID_ARRAY_NULLCOUNT: i += input.readUInt32(); break; default: throw new ProtostuffException("Corrupt input."); } } if (0 != input.readFieldNumber(this)) throw new ProtostuffException("Corrupt input."); return array; }
Example #20
Source File: ArraySchemas.java From protostuff with Apache License 2.0 | 5 votes |
@Override protected void transfer(Pipe pipe, Input input, Output output) throws IOException { if (ID_ARRAY_LEN != input .readFieldNumber(pipeSchema.wrappedSchema)) throw new ProtostuffException("Corrupt input."); final int len = input.readInt32(); // write it back output.writeInt32(ID_ARRAY_LEN, len, false); for (int i = 0, nullCount = 0; i < len;) { switch (input.readFieldNumber(pipeSchema.wrappedSchema)) { case ID_ARRAY_DATA: i++; output.writeObject(ID_ARRAY_DATA, pipe, hs.getPipeSchema(), true); break; case ID_ARRAY_NULLCOUNT: nullCount = input.readUInt32(); i += nullCount; output.writeUInt32(ID_ARRAY_NULLCOUNT, nullCount, false); break; default: throw new ProtostuffException("Corrupt input."); } } if (0 != input.readFieldNumber(pipeSchema.wrappedSchema)) throw new ProtostuffException("Corrupt input."); }
Example #21
Source File: ObjectSchema.java From protostuff with Apache License 2.0 | 5 votes |
static void transferClass(Pipe pipe, Input input, Output output, int number, Pipe.Schema<?> pipeSchema, boolean mapped, boolean array, IdStrategy strategy) throws IOException { strategy.transferClassId(input, output, number, mapped, array); if (array) { if (input.readFieldNumber(pipeSchema.wrappedSchema) != ID_ARRAY_DIMENSION) throw new ProtostuffException("Corrupt input."); output.writeUInt32(ID_ARRAY_DIMENSION, input.readUInt32(), false); } }
Example #22
Source File: ArraySchemas.java From protostuff with Apache License 2.0 | 5 votes |
@Override public Object readFrom(Input input, Object owner) throws IOException { if (ID_ARRAY_LEN != input.readFieldNumber(this)) throw new ProtostuffException("Corrupt input."); final int len = input.readInt32(); Object[] array = (Object[])Array.newInstance(delegate.typeClass(), len); if (input instanceof GraphInput) { // update the actual reference. ((GraphInput) input).updateLast(array, owner); } for (int i = 0; i < len;) { switch (input.readFieldNumber(this)) { case ID_ARRAY_DATA: array[i++] = delegate.readFrom(input); break; case ID_ARRAY_NULLCOUNT: i += input.readUInt32(); break; default: throw new ProtostuffException("Corrupt input."); } } if (0 != input.readFieldNumber(this)) throw new ProtostuffException("Corrupt input."); return array; }
Example #23
Source File: ClassSchema.java From protostuff with Apache License 2.0 | 5 votes |
static Object readObjectFrom(Input input, Schema<?> schema, Object owner, IdStrategy strategy) throws IOException { final int number = input.readFieldNumber(schema); final Object value; switch (number) { case ID_CLASS: value = strategy.resolveClassFrom(input, false, false); break; case ID_CLASS_MAPPED: value = strategy.resolveClassFrom(input, true, false); break; case ID_CLASS_ARRAY: value = ObjectSchema.getArrayClass(input, schema, strategy.resolveClassFrom(input, false, true)); break; case ID_CLASS_ARRAY_MAPPED: value = ObjectSchema.getArrayClass(input, schema, strategy.resolveClassFrom(input, true, true)); break; default: throw new ProtostuffException("Corrupt input."); } if (input instanceof GraphInput) { // update the actual reference. ((GraphInput) input).updateLast(value, owner); } if (0 != input.readFieldNumber(schema)) throw new ProtostuffException("Corrupt input."); return value; }
Example #24
Source File: ClassSchema.java From protostuff with Apache License 2.0 | 5 votes |
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."); }
Example #25
Source File: ArraySchema.java From protostuff with Apache License 2.0 | 5 votes |
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; }
Example #26
Source File: DefaultIdStrategy.java From protostuff with Apache License 2.0 | 5 votes |
@Override protected <T> HasSchema<T> resolvePojoFrom(Input input, int fieldNumber) throws IOException { final String className = input.readString(); final HasSchema<T> wrapper = getSchemaWrapper(className, 0 != (AUTO_LOAD_POLYMORPHIC_CLASSES & flags)); if (wrapper == null) throw new ProtostuffException("polymorphic pojo not registered: " + className); return wrapper; }
Example #27
Source File: DerivativeSchema.java From protostuff with Apache License 2.0 | 5 votes |
/** * Delegates to the schema derived from the input. The {@code owner} owns the message (polymorphic) that is tied to * this schema. */ @Override public void mergeFrom(Input input, final Object owner) throws IOException { final int first = input.readFieldNumber(this); if (first != ID_POJO) throw new ProtostuffException("order not preserved."); doMergeFrom(input, strategy.resolvePojoFrom(input, ID_POJO).getSchema(), owner); }
Example #28
Source File: PolymorphicThrowableSchema.java From protostuff with Apache License 2.0 | 5 votes |
static Object readObjectFrom(Input input, Schema<?> schema, Object owner, IdStrategy strategy) throws IOException { final int number = input.readFieldNumber(schema); if (number != ID_THROWABLE) throw new ProtostuffException("Corrupt input."); return readObjectFrom(input, schema, owner, strategy, number); }
Example #29
Source File: PolymorphicThrowableSchema.java From protostuff with Apache License 2.0 | 5 votes |
static void transferObject(Pipe.Schema<Object> pipeSchema, Pipe pipe, Input input, Output output, IdStrategy strategy) throws IOException { final int number = input.readFieldNumber(pipeSchema.wrappedSchema); if (number != ID_THROWABLE) throw new ProtostuffException("Corrupt input."); transferObject(pipeSchema, pipe, input, output, strategy, number); }
Example #30
Source File: SampleDelegates.java From protostuff with Apache License 2.0 | 5 votes |
@Override public Singleton readFrom(Input input) throws IOException { if (0 != input.readUInt32()) throw new ProtostuffException("Corrupt input."); return Singleton.INSTANCE; }