Package flex.messaging.io

Examples of flex.messaging.io.TypeMarshallingContext


*/
public class ReferenceAwareTypedObjectDecoder extends TypedObjectDecoder
{
    protected Object decodeTypedObject(Object bean, Object encodedObject)
    {
        TypeMarshallingContext context = TypeMarshallingContext.getTypeMarshallingContext();
        context.getKnownObjects().put(encodedObject, bean);

        PropertyProxy beanProxy = PropertyProxyRegistry.getProxy(bean);
        PropertyProxy encodedProxy = PropertyProxyRegistry.getProxy(encodedObject);

        List propertyNames = beanProxy.getPropertyNames(bean);
        if (propertyNames != null)
        {
            Iterator it = propertyNames.iterator();
            while (it.hasNext())
            {
                String propName = (String)it.next();

                Class wClass = beanProxy.getType(bean, propName);

                // get property value from encodedObject
                Object value = encodedProxy.getValue(encodedObject, propName);

                Object decodedObject = null;
                try
                {
                    if (value != null)
                    {
                        //Check whether we need to restore a client
                        //side reference to a known object
                        Object ref = null;
   
                        if (canUseByReference(value))
                            ref = context.getKnownObjects().get(value);
   
                        if (ref == null)
                        {
                            ActionScriptDecoder decoder = DecoderFactory.getReferenceAwareDecoder(value, wClass);
                            decodedObject = decoder.decodeObject(value, wClass);
   
                            if (canUseByReference(decodedObject))
                            {
                                context.getKnownObjects().put(value, decodedObject);
                            }
                        }
                        else
                        {
                            decodedObject = ref;
View Full Code Here


        if (shell == null) return null;

        Map shellMap = (Map)shell;
        Map encodedMap = (Map)encodedObject;

        TypeMarshallingContext context = TypeMarshallingContext.getTypeMarshallingContext();
        context.getKnownObjects().put(encodedObject, shell);

        ActionScriptDecoder decoder = null;
        Object key = null;
        Object value = null;
        Object decodedValue = null;
        for (Iterator keys = encodedMap.keySet().iterator(); keys.hasNext();)
        {
            key = keys.next();
            value = encodedMap.get(key);

            if (value == null)
            {
                shellMap.put(key, null);
                continue;
            }

            //Check whether we need to restore a client
            //side reference to a known object
            Object ref = null;

            if (canUseByReference(value))
                ref = context.getKnownObjects().get(value);

            if (ref == null)
            {
                decoder = DecoderFactory.getReferenceAwareDecoder(value, value.getClass());
                decodedValue = decoder.decodeObject(value, value.getClass());

                if (canUseByReference(decodedValue))
                {
                    context.getKnownObjects().put(value, decodedValue);
                }
            }
            else
            {
                decodedValue = ref;
View Full Code Here

    {
        Collection decodedCollection = (Collection)shell;
        Object decodedObject = null;
        Object obj = null;

        TypeMarshallingContext context = TypeMarshallingContext.getTypeMarshallingContext();
        ActionScriptDecoder decoder = null;

        if (encodedObject instanceof String)
        {
            encodedObject = ((String)encodedObject).toCharArray();
        }
        else
        {
            if (encodedObject instanceof Collection)
            {
                encodedObject = ((Collection)encodedObject).toArray();
            }

            context.getKnownObjects().put(encodedObject, shell);
        }

        int len = Array.getLength(encodedObject);

        for (int i = 0; i < len; i++)
        {
            obj = Array.get(encodedObject, i);

            if (obj == null)
            {
                decodedCollection.add(null);
            }
            else
            {
                //Check whether we need to restore a client
                //side reference to a known object
                Object ref = null;

                if (canUseByReference(obj))
                    ref = context.getKnownObjects().get(obj);

                if (ref == null)
                {
                    decoder = DecoderFactory.getReferenceAwareDecoder(obj, obj.getClass());
                    decodedObject = decoder.decodeObject(obj, obj.getClass());

                    if (canUseByReference(decodedObject))
                    {
                        context.getKnownObjects().put(obj, decodedObject);
                    }
                }
                else
                {
                    decodedObject = ref;
View Full Code Here

        // to the encodedObject if the incoming type was a Date object.
        if (result != null
                && SerializationContext.getSerializationContext().supportDatesByReference
                && encodedObject instanceof java.util.Date)
        {
            TypeMarshallingContext context = TypeMarshallingContext.getTypeMarshallingContext();
            context.getKnownObjects().put(encodedObject, result);
        }

        return result;
    }
View Full Code Here

    protected Object decodeArray(Object shellArray, Object array, Class arrayElementClass)
    {
        Object encodedValue = null;
        Object decodedValue = null;
        TypeMarshallingContext context = TypeMarshallingContext.getTypeMarshallingContext();
       
        ActionScriptDecoder decoder = null;
        int n = 0;
        int len = Array.getLength(array);
        for (int i = 0; i < len; i++)
        {
            encodedValue = Array.get(array, i);

            if (encodedValue == null)
            {
                Array.set(shellArray, n, null);
            }
            else
            {
                //Check whether we need to restore a client
                //side reference to a known object
                Object ref = null;

                if (canUseByReference(encodedValue))
                    ref = context.getKnownObjects().get(encodedValue);

                if (ref == null)
                {
                    decoder = DecoderFactory.getReferenceAwareDecoder(encodedValue, arrayElementClass);
                    decodedValue = decoder.decodeObject(encodedValue, arrayElementClass);

                    if (canUseByReference(decodedValue))
                    {
                        context.getKnownObjects().put(encodedValue, decodedValue);
                    }
                }
                else
                {
                    decodedValue = ref;
View Full Code Here

        Class cls;
        String type = TypeMarshallingContext.getType(encodedObject);

        if (type != null)
        {
            TypeMarshallingContext context = TypeMarshallingContext.getTypeMarshallingContext();
             cls = ClassUtil.createClass(type, context.getClassLoader());
        }
        else
        {
            cls = desiredClass;
        }
View Full Code Here

        // to the encodedObject if the incoming type was a Date object.
        if (result != null
                && SerializationContext.getSerializationContext().supportDatesByReference
                && encodedObject instanceof java.util.Date)
        {
            TypeMarshallingContext context = TypeMarshallingContext.getTypeMarshallingContext();
            context.getKnownObjects().put(encodedObject, result);
        }

        return result;
    }
View Full Code Here

     * Reset should be called before reading a top level object,
     * such as a new header or a new body.
     */
    public void reset()
    {
        TypeMarshallingContext marshallingContext = TypeMarshallingContext.getTypeMarshallingContext();
        marshallingContext.reset();
    }
View Full Code Here

        arrayPropertyStack.clear();
        traitsStack.clear();
        currentBody = null;
        currentHeader = null;

        TypeMarshallingContext marshallingContext = TypeMarshallingContext.getTypeMarshallingContext();
        marshallingContext.reset();
    }
View Full Code Here

    {
        Collection decodedCollection = (Collection)shell;
        Object decodedObject = null;
        Object obj = null;

        TypeMarshallingContext context = TypeMarshallingContext.getTypeMarshallingContext();
        ActionScriptDecoder decoder = null;

        if (encodedObject instanceof String)
        {
            encodedObject = ((String)encodedObject).toCharArray();
        }
        else
        {
            if (encodedObject instanceof Collection)
            {
                encodedObject = ((Collection)encodedObject).toArray();
            }

            context.getKnownObjects().put(encodedObject, shell);
        }

        int len = Array.getLength(encodedObject);

        for (int i = 0; i < len; i++)
        {
            obj = Array.get(encodedObject, i);

            if (obj == null)
            {
                decodedCollection.add(null);
            }
            else
            {
                //Check whether we need to restore a client
                //side reference to a known object
                Object ref = null;

                if (canUseByReference(obj))
                    ref = context.getKnownObjects().get(obj);

                if (ref == null)
                {
                    decoder = DecoderFactory.getReferenceAwareDecoder(obj, obj.getClass());
                    decodedObject = decoder.decodeObject(obj, obj.getClass());

                    if (canUseByReference(decodedObject))
                    {
                        context.getKnownObjects().put(obj, decodedObject);
                    }
                }
                else
                {
                    decodedObject = ref;
View Full Code Here

TOP

Related Classes of flex.messaging.io.TypeMarshallingContext

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.