org.spicefactory.cinnamon.io.mapping
Interface ClassMapping

All Known Implementing Classes:
AbstractClassMapping, AbstractPropertyClassMapping, AnonymousClassMapping, BeanClassMapping, EntityClassMapping, ExternalizableClassMapping

public interface ClassMapping

A class mapping instance encapsulates information and logic needed to map an ActionScript 3 class to a corresponding Java class. This includes properties for the alias and the mapped ActionScript and Java classes, a method to create a new instance of the mapped Java class and methods to read or write objects to/from AMF3 binary data.

Cinnamon includes implementations for three types of class mappings, representing the capabilities of the AMF3 format.

Author:
Jens Halm

Method Summary
 String getActionScriptClass()
          Returns the fully qualified name of the ActionScript 3 class for this mapping.
 String getAlias()
          Returns the alias that was registered for this mapping.
 Class<?> getJavaClass()
          Returns the Java class for this mapping.
 void init(CinnamonConfig config)
          Initialization method that will be called once for each ClassMapping instance at application startup.
 Object newJavaInstance()
          Creates a new instance of the mapped Java class.
 void readObject(Object instance, AMFInput input, ObjectEncoding encoding, String[] propertyNames)
          Restores the content of the given object from the AMFInput instance.
 void writeClassDescriptor(Object instance, AMFOutput output)
          Writes the class descriptor for the specified object to the given AMFOutput.
 void writeObject(Object instance, AMFOutput output)
          Writes the content of the specified object to the given AMFOutput.
 

Method Detail

init

void init(CinnamonConfig config)
Initialization method that will be called once for each ClassMapping instance at application startup.

Parameters:
config - the Cinnamon configuration instance

getAlias

String getAlias()
Returns the alias that was registered for this mapping. This must match the value that was set in ActionScript with registerClassAlias or the [RemoteClass] metadata tag.

Returns:
the alias for this mapping

getActionScriptClass

String getActionScriptClass()
Returns the fully qualified name of the ActionScript 3 class for this mapping.

Returns:
the fully qualified name of the ActionScript 3 class

getJavaClass

Class<?> getJavaClass()
Returns the Java class for this mapping.

Returns:
the Java class for this mapping

newJavaInstance

Object newJavaInstance()
Creates a new instance of the mapped Java class.

Returns:
a new instance of the mapped Java class

readObject

void readObject(Object instance,
                AMFInput input,
                ObjectEncoding encoding,
                String[] propertyNames)
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

void writeObject(Object instance,
                 AMFOutput output)
Writes the content of the specified object to the given AMFOutput.

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

writeClassDescriptor

void writeClassDescriptor(Object instance,
                          AMFOutput output)
Writes the class descriptor for the specified object to the given AMFOutput.

Parameters:
instance - the object a class descriptor should be written for
output - the output to write to