Package com.dyuproject.protostuff

Examples of com.dyuproject.protostuff.ProtostuffException


            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)
        {
View Full Code Here


        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);
        }
    }
View Full Code Here

   
    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)
View Full Code Here

               
                return arrayWrapper.array;
            }  
            case ID_OBJECT:
                if(input.readUInt32() != 0)
                    throw new ProtostuffException("Corrupt input.");
               
                value = new Object();
               
                break;
               
            case ID_ARRAY_MAPPED:
            {
                final ArrayWrapper mArrayWrapper = newArrayWrapper(input, schema, true,
                        strategy);
               
                if(input instanceof GraphInput)
                {
                    // update the actual reference.
                    ((GraphInput)input).updateLast(mArrayWrapper.array, owner);
                }
               
                strategy.COLLECTION_SCHEMA.mergeFrom(input, mArrayWrapper);
               
                return mArrayWrapper.array;
            }  
            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 = getArrayClass(input, schema,
                        strategy.resolveClassFrom(input, false, true));
                break;
            case ID_CLASS_ARRAY_MAPPED:
                value = getArrayClass(input, schema,
                        strategy.resolveClassFrom(input, true, true));
                break;
               
            case ID_ENUM:
            {
                final EnumIO<?> eio = strategy.resolveEnumFrom(input);
               
                if(input.readFieldNumber(schema) != ID_ENUM_VALUE)
                    throw new ProtostuffException("Corrupt input.");
               
                value = eio.readFrom(input);
                break;
            }  
            case ID_ENUM_SET:
            {
                final Collection<?> es = strategy.resolveEnumFrom(input).newEnumSet();
               
                if(input instanceof GraphInput)
                {
                    // update the actual reference.
                    ((GraphInput)input).updateLast(es, owner);
                }
               
                strategy.COLLECTION_SCHEMA.mergeFrom(input, (Collection<Object>)es);
               
                return es;
            }  
            case ID_ENUM_MAP:
            {
                final Map<?,Object> em = strategy.resolveEnumFrom(input).newEnumMap();
               
                if(input instanceof GraphInput)
                {
                    // update the actual reference.
                    ((GraphInput)input).updateLast(em, owner);
                }
               
                strategy.MAP_SCHEMA.mergeFrom(input, (Map<Object, Object>)em);
               
                return em;
            }  
            case ID_COLLECTION:
            {
                final Collection<Object> collection = strategy.resolveCollectionFrom(
                        input).newMessage();
               
                if(input instanceof GraphInput)
                {
                    // update the actual reference.
                    ((GraphInput)input).updateLast(collection, owner);
                }
               
                strategy.COLLECTION_SCHEMA.mergeFrom(input, collection);
               
                return collection;
            }  
            case ID_MAP:
            {
                final Map<Object,Object> map =
                    strategy.resolveMapFrom(input).newMessage();
               
                if(input instanceof GraphInput)
                {
                    // update the actual reference.
                    ((GraphInput)input).updateLast(map, owner);
                }
               
                strategy.MAP_SCHEMA.mergeFrom(input, map);
               
                return map;
            }
            case ID_POLYMORPHIC_COLLECTION:
            {
                if(0 != input.readUInt32())
                    throw new ProtostuffException("Corrupt input.");
               
                final Object collection = PolymorphicCollectionSchema.readObjectFrom(input,
                        strategy.POLYMORPHIC_COLLECTION_SCHEMA, owner, strategy);
               
                if(input instanceof GraphInput)
                {
                    // update the actual reference.
                    ((GraphInput)input).updateLast(collection, owner);
                }
               
                return collection;
            }
            case ID_POLYMORPHIC_MAP:
            {
                if(0 != input.readUInt32())
                    throw new ProtostuffException("Corrupt input.");
               
                final Object map = PolymorphicMapSchema.readObjectFrom(input,
                        strategy.POLYMORPHIC_MAP_SCHEMA, owner, strategy);
               
                if(input instanceof GraphInput)
                {
                    // update the actual reference.
                    ((GraphInput)input).updateLast(map, owner);
                }
               
                return map;
            }
            case ID_DELEGATE:
            {
                final Delegate<Object> delegate = strategy.resolveDelegateFrom(input);
                if(1 != input.readFieldNumber(schema))
                    throw new ProtostuffException("Corrupt input.");
               
                value = delegate.readFrom(input);
                break;
            }
            case ID_THROWABLE:
                return PolymorphicThrowableSchema.readObjectFrom(input, schema, owner,
                        strategy, number);
            case ID_POJO:
            {
                final Schema<Object> derivedSchema = strategy.resolvePojoFrom(
                        input, number).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;
    }
View Full Code Here

               
            case ID_ENUM:
                strategy.transferEnumId(input, output, number);
               
                if(input.readFieldNumber(pipeSchema.wrappedSchema) != ID_ENUM_VALUE)
                    throw new ProtostuffException("Corrupt input.");
               
                EnumIO.transfer(pipe, input, output, 1, false);
                break;
            case ID_ENUM_SET:
                strategy.transferEnumId(input, output, number);
               
                if(output instanceof StatefulOutput)
                {
                    // update using the derived schema.
                    ((StatefulOutput)output).updateLast(strategy.COLLECTION_PIPE_SCHEMA, pipeSchema);
                }
               
                Pipe.transferDirect(strategy.COLLECTION_PIPE_SCHEMA, pipe, input, output);
                return;
            case ID_ENUM_MAP:
                strategy.transferEnumId(input, output, number);
               
                if(output instanceof StatefulOutput)
                {
                    // update using the derived schema.
                    ((StatefulOutput)output).updateLast(strategy.MAP_PIPE_SCHEMA, pipeSchema);
                }
               
                Pipe.transferDirect(strategy.MAP_PIPE_SCHEMA, pipe, input, output);
                return;
            case ID_COLLECTION:
                strategy.transferCollectionId(input, output, number);
               
                if(output instanceof StatefulOutput)
                {
                    // update using the derived schema.
                    ((StatefulOutput)output).updateLast(strategy.COLLECTION_PIPE_SCHEMA, pipeSchema);
                }
               
                Pipe.transferDirect(strategy.COLLECTION_PIPE_SCHEMA, pipe, input, output);
                return;
            case ID_MAP:
                strategy.transferMapId(input, output, number);
               
                if(output instanceof StatefulOutput)
                {
                    // update using the derived schema.
                    ((StatefulOutput)output).updateLast(strategy.MAP_PIPE_SCHEMA, pipeSchema);
                }
               
                Pipe.transferDirect(strategy.MAP_PIPE_SCHEMA, pipe, input, output);
                return;
               
            case ID_POLYMORPHIC_COLLECTION:
                if(0 != input.readUInt32())
                    throw new ProtostuffException("Corrupt input.");
                output.writeUInt32(number, 0, false);
               
                if(output instanceof StatefulOutput)
                {
                    // update using the derived schema.
                    ((StatefulOutput)output).updateLast(
                            strategy.POLYMORPHIC_COLLECTION_PIPE_SCHEMA, pipeSchema);
                }
               
                Pipe.transferDirect(strategy.POLYMORPHIC_COLLECTION_PIPE_SCHEMA,
                        pipe, input, output);
                return;
               
            case ID_POLYMORPHIC_MAP:
                if(0 != input.readUInt32())
                    throw new ProtostuffException("Corrupt input.");
                output.writeUInt32(number, 0, false);
               
                if(output instanceof StatefulOutput)
                {
                    // update using the derived schema.
                    ((StatefulOutput)output).updateLast(
                            strategy.POLYMORPHIC_MAP_PIPE_SCHEMA, pipeSchema);
                }
               
                Pipe.transferDirect(strategy.POLYMORPHIC_MAP_PIPE_SCHEMA,
                        pipe, input, output);
                return;
            case ID_DELEGATE:
            {
                final Delegate<Object> delegate = strategy.transferDelegateId(input,
                        output, number);
                if(1 != input.readFieldNumber(pipeSchema.wrappedSchema))
                    throw new ProtostuffException("Corrupt input.");
               
                delegate.transfer(pipe, input, output, 1, false);
                break;
            }
           
            case ID_THROWABLE:
                PolymorphicThrowableSchema.transferObject(pipeSchema, pipe, input,
                        output, strategy, number);
                return;
               
            case ID_POJO:
                final Pipe.Schema<Object> derivedPipeSchema = strategy.transferPojoId(
                        input, output, number).getPipeSchema();
               
                if(output instanceof StatefulOutput)
                {
                    // update using the derived schema.
                    ((StatefulOutput)output).updateLast(derivedPipeSchema, pipeSchema);
                }
               
                Pipe.transferDirect(derivedPipeSchema, pipe, input, output);
                return;
            default:
                throw new ProtostuffException("Corrupt input.  Unknown field number: " + number);
        }
       
        if(input.readFieldNumber(pipeSchema.wrappedSchema) != 0)
            throw new ProtostuffException("Corrupt input.");
    }
View Full Code Here

       
        final HasSchema<T> wrapper = getSchemaWrapper(className,
                RuntimeEnv.AUTO_LOAD_POLYMORPHIC_CLASSES);
        if(wrapper == null)
        {
            throw new ProtostuffException("polymorphic pojo not registered: " +
                    className);
        }
       
        output.writeString(fieldNumber, className, false);
       
View Full Code Here

        final String className = input.readString();
       
        final HasSchema<T> wrapper = getSchemaWrapper(className,
                RuntimeEnv.AUTO_LOAD_POLYMORPHIC_CLASSES);
        if(wrapper == null)
            throw new ProtostuffException("polymorphic pojo not registered: " + className);
       
        return wrapper;
    }
View Full Code Here

    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);
    }
View Full Code Here

    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);
    }
View Full Code Here

            case ID_ARRAY_MAPPED:
                mapped = true;
                break;
           
            default:
                throw new ProtostuffException("Corrupt input.");
        }
       
        final ArrayWrapper mArrayWrapper = ObjectSchema.newArrayWrapper(input,
                schema, mapped, strategy);
       
View Full Code Here

TOP

Related Classes of com.dyuproject.protostuff.ProtostuffException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.