org.spicefactory.cinnamon.io.mapping
Class AbstractPropertyClassMapping

java.lang.Object
  extended by org.spicefactory.cinnamon.io.mapping.AbstractClassMapping
      extended by org.spicefactory.cinnamon.io.mapping.AbstractPropertyClassMapping
All Implemented Interfaces:
ClassMapping
Direct Known Subclasses:
AnonymousClassMapping, BeanClassMapping

public abstract class AbstractPropertyClassMapping
extends AbstractClassMapping

Abstract base class for mappings that deal with properties. Serves as a common base class for AnonymousClassMapping and BeanClassMapping. Contains the IO logic for reading/writing properties from AMF3 binary data. Subclasses only need to implement the logic for writing/reading these properties from/to the mapped instances.

Author:
Jens Halm

Constructor Summary
protected AbstractPropertyClassMapping(String alias, String actionScriptClass, Class<?> javaClass, Class<?> javaFactory, ObjectEncoding encoding)
          Creates a new ClassMapping instance.
 
Method Summary
protected abstract  Object getProperty(Object instance, String propertyName)
          Reads the property with the given name from the specified target instance.
 void readObject(Object instance, AMFInput input, ObjectEncoding encoding, String[] propertyNames)
          Restores the content of the given object from the AMFInput instance.
protected abstract  void setProperty(Object instance, String propertyName, Object value)
          Sets the property on the given target instance to the specified value.
 void writeObject(Object instance, AMFOutput output)
          Writes the content of the specified object to the given AMFOutput.
 
Methods inherited from class org.spicefactory.cinnamon.io.mapping.AbstractClassMapping
getActionScriptClass, getAlias, getEncoding, getJavaClass, getJavaFactory, getPropertyNames, setPropertyNames, toString, writeClassDescriptor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.spicefactory.cinnamon.io.mapping.ClassMapping
init, newJavaInstance
 

Constructor Detail

AbstractPropertyClassMapping

protected AbstractPropertyClassMapping(String alias,
                                       String actionScriptClass,
                                       Class<?> javaClass,
                                       Class<?> javaFactory,
                                       ObjectEncoding encoding)
Creates a new ClassMapping instance.

Parameters:
alias - the alias for this mapping
actionScriptClass - the fully qualified ActionScript class name
javaClass - the Java class
javaFactory - the (optional) Java factory
encoding - the object encoding for this mapping
Method Detail

readObject

public void readObject(Object instance,
                       AMFInput input,
                       ObjectEncoding encoding,
                       String[] propertyNames)
Description copied from interface: ClassMapping
Restores the content of the given object from the AMFInput instance.

Parameters:
instance - the object to be restored
input - the AMF3 data to read from
encoding - the type of object encoding to use
propertyNames - the names of the properties of the object (may be empty for some kinds of mappings)

writeObject

public void writeObject(Object instance,
                        AMFOutput output)
Description copied from interface: ClassMapping
Writes the content of the specified object to the given AMFOutput.

Parameters:
instance - the object to be serialized
output - the output to write to

setProperty

protected abstract void setProperty(Object instance,
                                    String propertyName,
                                    Object value)
Sets the property on the given target instance to the specified value.

Parameters:
instance - the instance to set the property on
propertyName - the name of the property
value - the new value of the property

getProperty

protected abstract Object getProperty(Object instance,
                                      String propertyName)
Reads the property with the given name from the specified target instance.

Parameters:
instance - the instance to read the property from
propertyName - the name of the property
Returns:
the value of the property