Package com.dyuproject.protostuff

Examples of com.dyuproject.protostuff.ProtostuffException


     */
    public void mergeFrom(Input input, final Object owner) throws IOException
    {
        final int first = input.readFieldNumber(this);
        if(first != 127)
            throw new ProtostuffException("order not preserved.");
       
        final String className = input.readString();
        final HasSchema<Object> wrapper = RuntimeSchema.getSchemaWrapper(className,
                AUTO_LOAD_POLYMORPHIC_CLASSES);
       
        if(wrapper == null)
            throw new ProtostuffException("polymorphic pojo not registered: " + className);
       
        doMergeFrom(input, wrapper.getSchema(), owner);
    }
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);
               
                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,
                        RuntimeSchema.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();
                    COLLECTION_SCHEMA.mergeFrom(input, (Collection<Object>)c);
                    return c;
                }
               
                final Collection<Object> collection =
                    CollectionSchema.MessageFactories.getFactory(
                            collectionType).newMessage();
               
                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();
                    MAP_SCHEMA.mergeFrom(input, (Map<Object, Object>)m);
                    return m;
                }
               
                final Map<Object,Object> map =
                    MapSchema.MessageFactories.getFactory(mapType).newMessage();
               
                MAP_SCHEMA.mergeFrom(input, map);
               
                return map;
               
            case ID_POJO:
                final String typePojo = input.readString();
                final HasSchema<Object> wrapper = RuntimeSchema.getSchemaWrapper(
                        typePojo, RuntimeSchema.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();
               
                derivedSchema.mergeFrom(input, pojo);
                return pojo;
               
            default:
                throw new ProtostuffException("Corrupt input.  Unknown field number: " + number);
        }
       
        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, RuntimeSchema.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

     */
    public void mergeFrom(Input input, final Object owner) throws IOException
    {
        final int first = input.readFieldNumber(this);
        if(first != 127)
            throw new ProtostuffException("order not preserved.");
       
        final String className = input.readString();
        final HasSchema<Object> wrapper = RuntimeSchema.getSchemaWrapper(className,
                RuntimeSchema.AUTO_LOAD_POLYMORPHIC_CLASSES);
       
        if(wrapper == null)
            throw new ProtostuffException("polymorphic pojo not registered: " + className);
       
        doMergeFrom(input, wrapper.getSchema(), owner);
    }
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.