flex.messaging.io
Interface PropertyProxy

All Superinterfaces:
Cloneable
All Known Implementing Classes:
AbstractProxy, BeanProxy, DictionaryProxy, MapProxy, PageableRowSetProxy, SerializationProxy, StatusInfoProxy, ThrowableProxy

public interface PropertyProxy
extends Cloneable

A PropertyProxy allows customized serialization and deserialization of complex objects by providing access to each of the steps in the serialization and deserialization process. A serializer asks a PropertyProxy for the class name, traits and properties during serialization. A deserializer asks a PropertyProxy to create a new instance and set property values. Different PropertyProxy implementations may be written for different types of objects such as Map, Dictionary, Enumerable, Throwable, and Beans.


Method Summary
 Object clone()
          Returns a copy of the PropertyProxy so that it can be used as a template without modifying/creating global references to instances, descriptors etc.
 Object createInstance(String className)
          Creates a new instance for the given className.
 String getAlias()
          The class name alias for the default instance.
 String getAlias(Object instance)
          The class name alias for the given instance.
 Object getDefaultInstance()
          The default instance managed by this PropertyProxy.
 SerializationDescriptor getDescriptor()
          A serialization descriptor that provides overrides to the default behavior for selecting properties for serialization.
 boolean getIncludeReadOnly()
          Determines whether read only properties from the instance should be included during default serialization.
 Object getInstanceToSerialize(Object instance)
          This is called right before we are about to serialize the supplied instance.
 List getPropertyNames()
          The List of property names as Strings that make up the traits of the default instance.
 List getPropertyNames(Object instance)
          The List of property names as Strings that make up the traits of the given instance.
 SerializationContext getSerializationContext()
          The context holds settings that govern serialization behavior.
 Class getType(Object instance, String propertyName)
          Looks up the Class type of the property by name on the given instance.
 Class getType(String propertyName)
          Looks up the Class type of the property by name on the default instance.
 Object getValue(Object instance, String propertyName)
          Looks up the value of a property by name for the given instance.
 Object getValue(String propertyName)
          Looks up the value of the property by name from the default instance.
 Object instanceComplete(Object instance)
          This is called after the deserialization of the instance is complete (i.e.
 boolean isDynamic()
          The trait setting "dynamic" is a client-only concept for types that allow for arbitrary public properties to be defined at runtime.
 boolean isExternalizable()
          Specifies whether the default instance manages its own serialization through the Externalizable interface.
 boolean isExternalizable(Object instance)
          Specifies whether the given instance manages its own serialization through the Externalizable interface.
 void setAlias(String value)
          Allows an alias to be set for the instance type.
 void setDefaultInstance(Object defaultInstance)
          Sets the default instance managed by this PropertyProxy.
 void setDescriptor(SerializationDescriptor descriptor)
          Allows non-default inclusion/exclusion of properties for serialization.
 void setDynamic(boolean value)
          Dynamic is a client-only concept for types that allow for arbitrary public properties to be defined at runtime.
 void setExternalizable(boolean value)
          Specifies whether the given instance manages its own serialization through the Externalizable interface.
 void setIncludeReadOnly(boolean value)
          If set to true, read only properties will be included during default serialization.
 void setSerializationContext(SerializationContext value)
          Sets the context for serialization behavior.
 void setValue(Object instance, String propertyName, Object value)
          Updates the value of a property by name for the given instance.
 void setValue(String propertyName, Object value)
          Updates the value of a propery by name for the default instance.
 

Method Detail

getDefaultInstance

Object getDefaultInstance()
The default instance managed by this PropertyProxy. The default instance is used for one-type proxied instances.

Returns:
The proxied instance.

setDefaultInstance

void setDefaultInstance(Object defaultInstance)
Sets the default instance managed by this PropertyProxy.

Parameters:
defaultInstance - The default instance.

createInstance

Object createInstance(String className)
Creates a new instance for the given className. ClassName is the value of the "alias" for the ActionScript class serialized. If the className is invalid an anonymous ASObject is created. If the className is prefixed with ">" an ASObject is created with the type set however a concrete instance is not instantiated.

Parameters:
className - the class to create
Returns:
an instance of className

getPropertyNames

List getPropertyNames()
The List of property names as Strings that make up the traits of the default instance. These traits determine which properties are to be serialized.

Returns:
The set of property names as Strings to be serialized.

getPropertyNames

List getPropertyNames(Object instance)
The List of property names as Strings that make up the traits of the given instance. These traits determine which properties are to be serialized.

Parameters:
instance - the object to examine
Returns:
List of property names as Strings to be serialized.

getType

Class getType(String propertyName)
Looks up the Class type of the property by name on the default instance.

Parameters:
propertyName - The name of the property.
Returns:
The property type.

getType

Class getType(Object instance,
              String propertyName)
Looks up the Class type of the property by name on the given instance.

Parameters:
instance - The instance that possesses the property.
propertyName - The name of the property.
Returns:
The property type.

getValue

Object getValue(String propertyName)
Looks up the value of the property by name from the default instance.

Parameters:
propertyName - The name of the property.
Returns:
The value of the given property.

getValue

Object getValue(Object instance,
                String propertyName)
Looks up the value of a property by name for the given instance.

Parameters:
instance - The instance that possesses the requested property.
propertyName - The name of the property.
Returns:
The value of the given property.

setValue

void setValue(String propertyName,
              Object value)
Updates the value of a propery by name for the default instance.

Parameters:
propertyName - the property name
value - the new value

setValue

void setValue(Object instance,
              String propertyName,
              Object value)
Updates the value of a property by name for the given instance.

Parameters:
instance - The instance that possesses the requested property.
propertyName - The name of the property to update.
value - The updated value for the property.

instanceComplete

Object instanceComplete(Object instance)
This is called after the deserialization of the instance is complete (i.e. after the lastSetValue call. It has the opportunity to return an instance to use to replace the instance returned previously in createInstance. NOTE however that this approach does not support recursive references back to this same object (i.e. if a property of this object refers back to itself).

Parameters:
instance - the instance being deserialized (previously returned from a createInstance call)
Returns:
possibly the same instance to use for this object.

setAlias

void setAlias(String value)
Allows an alias to be set for the instance type. By default the classname of the instance is used.

Parameters:
value - The class name alias.

getAlias

String getAlias()
The class name alias for the default instance.

Returns:
The class name alias to be used in serializing the type traits.

getAlias

String getAlias(Object instance)
The class name alias for the given instance.

Parameters:
instance - the object to get the alias of.
Returns:
The class name alias to be used in serializing the type traits.

setDynamic

void setDynamic(boolean value)
Dynamic is a client-only concept for types that allow for arbitrary public properties to be defined at runtime. This setting isn't yet relevant for serialization but can still be set in the Object traits.

Parameters:
value - Whether the client type is expected to be dynamic. This setting is currently not used.

isDynamic

boolean isDynamic()
The trait setting "dynamic" is a client-only concept for types that allow for arbitrary public properties to be defined at runtime. The default is false and it is unlikely that it would need to be set.

Returns:
The dynamic client trait setting to be used during serialization of the type.

isExternalizable

boolean isExternalizable()
Specifies whether the default instance manages its own serialization through the Externalizable interface.

Returns:
Whether the default instance implements java.io.Externalizable.

isExternalizable

boolean isExternalizable(Object instance)
Specifies whether the given instance manages its own serialization through the Externalizable interface.

Parameters:
instance - the object to check
Returns:
Whether the given instance implements java.io.Externalizable.

setExternalizable

void setExternalizable(boolean value)
Specifies whether the given instance manages its own serialization through the Externalizable interface. If this property is set to true then the type must implement java.io.Externalizable. Setting this property to false allows an otherwise Externalizable instance to be considered as a normal type for custom serialization.

Parameters:
value - if set to true the instance must implement java.io.Externalizable, otherwise if set to false the proxied type can avoid external serialization for an otherwise Externalizable type.

getSerializationContext

SerializationContext getSerializationContext()
The context holds settings that govern serialization behavior.

Returns:
The current serialization context, or a new default instance if undefined.

setSerializationContext

void setSerializationContext(SerializationContext value)
Sets the context for serialization behavior.

Parameters:
value - the new context

setIncludeReadOnly

void setIncludeReadOnly(boolean value)
If set to true, read only properties will be included during default serialization. The default is false.

Parameters:
value - whether read only properties should be included.

getIncludeReadOnly

boolean getIncludeReadOnly()
Determines whether read only properties from the instance should be included during default serialization. The default is false.

Returns:
Whether read only properties should be included during default serialization.

getDescriptor

SerializationDescriptor getDescriptor()
A serialization descriptor that provides overrides to the default behavior for selecting properties for serialization. At any given level a list of includes and excludes can be specified. Complex child properties can have their own descriptors specified in a nested manner.

Returns:
The serialization descriptor for custom serialization.

setDescriptor

void setDescriptor(SerializationDescriptor descriptor)
Allows non-default inclusion/exclusion of properties for serialization.

Parameters:
descriptor - The descriptor to customize property selection for serialization.

clone

Object clone()
Returns a copy of the PropertyProxy so that it can be used as a template without modifying/creating global references to instances, descriptors etc.

Returns:
A copy of the PropertyProxy.

getInstanceToSerialize

Object getInstanceToSerialize(Object instance)
This is called right before we are about to serialize the supplied instance. You can override this method to serialize an instance which you want to serialize instead of the instance encountered in the object graph. If you return an instance of a different class, we use the PropertyProxyRegistry to get a new proxy for that instance. That proxy is then used during the rest of the serialization. Note that the objects returned from this method should be serialized through their properties. You cannot return a String, Integer or other primitive type.

Parameters:
instance - the instance encountered during AMF serialization
Returns:
the instance you want to serialize in its place


Copyright © 2008 Adobe Systems Inc. All Rights Reserved.

 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/blazeds/1/javadoc/flex/messaging/io/PropertyProxy.html