Package com.dyuproject.protostuff

Examples of com.dyuproject.protostuff.ProtostuffException


                ObjectSchema.transferArray(pipe, input, output, number, pipeSchema,
                        true, strategy);
                return;
               
            default:
                throw new ProtostuffException("Corrupt input.");
        }
    }
View Full Code Here


     */
    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);
    }
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

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

            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

               
                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_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_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

                return;
            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_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

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

                break;
            case ID_ARRAY:
                input.transferByteRangeTo(output, true, number, false);
               
                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(ARRAY_PIPE_SCHEMA, pipeSchema);
                }
               
                Pipe.transferDirect(ARRAY_PIPE_SCHEMA, pipe, input, output);
                return;
            case ID_OBJECT:
                output.writeUInt32(number, input.readUInt32(), false);
                break;
            case ID_ENUM:
                input.transferByteRangeTo(output, true, number, false);
               
                if(input.readFieldNumber(pipeSchema.wrappedSchema) != ID_ENUM_VALUE)
                    throw new ProtostuffException("Corrupt input.");
               
                EnumIO.transfer(pipe, input, output, 1, false);
                break;
            case ID_COLLECTION:
                input.transferByteRangeTo(output, true, number, false);
               
                if(output instanceof StatefulOutput)
                {
                    // update using the derived schema.
                    ((StatefulOutput)output).updateLast(COLLECTION_PIPE_SCHEMA, pipeSchema);
                }
               
                Pipe.transferDirect(COLLECTION_PIPE_SCHEMA, pipe, input, output);
                return;
            case ID_MAP:
                input.transferByteRangeTo(output, true, number, false);
               
                if(output instanceof StatefulOutput)
                {
                    // update using the derived schema.
                    ((StatefulOutput)output).updateLast(MAP_PIPE_SCHEMA, pipeSchema);
                }
               
                Pipe.transferDirect(MAP_PIPE_SCHEMA, pipe, input, output);
                return;
            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);
               
                output.writeString(number, typePojo, false);
               
                final Pipe.Schema<Object> derivedPipeSchema = wrapper.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

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.