|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.carbonfive.flash.ASTranslator
public class ASTranslator
ASTranslator provides the ability to translate between ASObjects used by Macromedia Flash Remoting and Java objects in your application. See the project documentation for details.
$Id: ASTranslator.java,v 1.27 2004/03/03 20:42:38 wynholds Exp $
Constructor Summary | |
---|---|
ASTranslator()
|
Method Summary | |
---|---|
java.lang.Object |
fromActionScript(java.lang.Object asObject)
Given an Object that is either an ASObject or Collection of ASObjects, fromActionScript creates a corresponding JavaBean or Collection of JavaBeans. |
java.lang.Object |
fromActionScript(java.lang.Object actionScriptObject,
java.lang.Class desiredBeanClass)
Translate an object to another object of type 'desiredBeanClass' obj types should be ASObject, Boolean, String, Number, Date, ArrayList |
void |
ignoreClass(java.lang.Class klass)
Ignore objects that are an instance of klass when translating. |
void |
ignoreProperty(java.lang.Class klass,
java.lang.String property)
Ignore the specified property of objects that are instances of
klass . |
void |
setUseEquivalence(boolean b)
Determines whether object that are equivalent (using Object.equals()) should be considered identical by ASTranslator. |
java.lang.Object |
toActionScript(java.lang.Object serverObject)
Given an Object, toActionScript creates a corresponding ASObject or Collection of ASObjects that maps the source object's JavaBean properties to ASObject fields, Collections and Sets to ArrayLists, and all Numbers to Doubles while maintaining object references (including circular references). |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ASTranslator()
Method Detail |
---|
public void ignoreClass(java.lang.Class klass)
klass
when translating. For
example, ignoreClass(Object.class)
would cause ASTranslator to ignore
everything.
klass
- The class (or superclass or interface) to ignorepublic void ignoreProperty(java.lang.Class klass, java.lang.String property)
property
of objects that are instances of
klass
.
Properties that are ignored are returned from ASTranslator as null.
klass
- The class (or superclass or interface) of the property to ignoreproperty
- The name of the property to ignorepublic void setUseEquivalence(boolean b)
When walking the object graph ASTranslator stores a cache of objects viewed. This
cache is used to maintain references within the object graph. If useEquivalence
is set to true, this cache is an equivalence cache, which means objects are compared by
Object.equals() instead of the == operator. So if two objects are equal (but not
identical) in the object graph, one will be stored as a reference to the other one when
translated to ASObjects.
The consequences of this are:
You should use this only if your Flash code is using the ASObjects in a read-only manner, or you are very well aware of what is going on.
This setting also assumes that the Flash Remoting gateway supports maintaining references. Unfortunately, this is not currently the case. However, it is pretty easy to hack this behavior in to Flash Remoting or OpenAMF.
The default value for useEquivalence
is false.
b
- Whether to use equivalence or notpublic java.lang.Object toActionScript(java.lang.Object serverObject)
These mappings are consistent with Flash Remoting's rules for converting Objects to ASObjects. They just add the behavior of using JavaBean-style introspection to determine property names. Additionally, toActionScript sets the "type" field of all ASObjects created to be the class name of the source JavaBean. This enables two-way translation between ASObjects and JavaBeans.
serverObject
- an Object to translate to ASObjects or
corresponding primitive or Collection classes
public java.lang.Object fromActionScript(java.lang.Object asObject)
The "type" field of an ASObject identifies the class name of the JavaBean to create. If the type field is null, an ASObject becomes a HashMap. The interface of the JavaBean is more specific that the relatively loosely-typed ASObject and therefore drives the translation of ASObject fields.
asObject
- an Object that is usually an ASObject but may also be
a Collection or primitive
public java.lang.Object fromActionScript(java.lang.Object actionScriptObject, java.lang.Class desiredBeanClass)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |