Package org.sf.bee.commons.remoting.jrpc.serializer

Examples of org.sf.bee.commons.remoting.jrpc.serializer.ProcessedObject


            }
            return JSONObject.NULL;
        }

        // check for duplicate objects or circular references
        ProcessedObject p = state.getProcessedObject(java);

        // if this object hasn't been seen before, mark it as seen and continue forth
        if (p == null) {
            state.push(parent, java, ref);
        } else {
            //todo: make test cases to explicitly handle all 4 combinations of the 2 option
            //todo: settings (both on the client and server)

            // handle throwing of circular reference exception and/or serializing duplicates, depending
            // on the options set in the serializer!
            boolean foundCircRef = state.isAncestor(p, parent);

            // throw an exception if a circular reference found, and the
            // serializer option is not set to fixup these circular references
            if (!_fixupCircRefs && foundCircRef) {
                throw new MarshallException("Circular Reference");
            }

            // if its a duplicate only, and we aren't fixing up duplicates or if
            // it is a primitive, and fixing up of primitives is not allowed then
            // re-serialize the object into the json.
            if (!foundCircRef
                    && (!_fixupDuplicates || (!_fixupDuplicatePrimitives && isPrimitive(java)))) {
                //todo: if a duplicate is being reserialized... it will overwrite the original location of the
                //todo: first one found... need to think about the ramifications of this -- optimally, circ refs found
                //todo: underneath duplicates need to point to the "original" one found, but they also need to be fixed
                //todo: up to the correct location, of course.
                state.push(parent, java, ref);
            } else {
                // generate a fix up entry for the duplicate/circular reference
                state.addFixUp(p.getLocation(), ref);
                return CIRC_REF_OR_DUPLICATE;
            }
        }

        try {
View Full Code Here


     * @throws UnmarshallException if getClassFromHint() fails
     */
    public ObjectMatch tryUnmarshall(SerializerState state, Class clazz,
            Object json) throws UnmarshallException {
        // check for duplicate objects or circular references
        ProcessedObject p = state.getProcessedObject(json);

        // if this object hasn't been seen before, mark it as seen and continue forth

        if (p == null) {
            p = state.store(json);
        } else {
            // get original serialized version
            // to recreate circular reference / duplicate object on the java side
            return (ObjectMatch) p.getSerialized();
        }

        /*
         * If we have a JSON object class hint that is a sub class of the signature
         * 'clazz', then override 'clazz' with the hint class.
View Full Code Here

     *           java.
     */
    public Object unmarshall(SerializerState state, Class clazz, Object json)
            throws UnmarshallException {
        // check for duplicate objects or circular references
        ProcessedObject p = state.getProcessedObject(json);

        // if this object hasn't been seen before, mark it as seen and continue forth

        if (p == null) {
            p = state.store(json);
        } else {
            // get original serialized version
            // to recreate circular reference / duplicate object on the java side
            return p.getSerialized();
        }

        // If we have a JSON object class hint that is a sub class of the
        // signature 'clazz', then override 'clazz' with the hint class.
        if (clazz != null && json instanceof JSONObject
View Full Code Here

TOP

Related Classes of org.sf.bee.commons.remoting.jrpc.serializer.ProcessedObject

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.