com.openharbor.beck.get
Class ExpansionGetter

java.lang.Object
  extended bycom.openharbor.beck.get.DefaultGetter
      extended bycom.openharbor.beck.get.ExpansionGetter
All Implemented Interfaces:
Configurable, Getter

public class ExpansionGetter
extends DefaultGetter
implements Configurable

Used in conjunction with ExpansionMarshaller to marshal several properties to an element with several sub-elements. This Getter creates the illusion of a child object with grandchild objects, but the child doesn't really exist, and the grandchildren are really children. The name of the illusory child is configured with a property attribute, thus: <choose getter="ExpansionGetter" property="propertyName"/> The class of the illusory child is the class of its parent; consequently the configuration must carefully avoid confusing them.

For example, an Assets JavaBean with a pair of properties named moneyAmount and moneyCurrency can map to:

<assets>
     <money>
         <amount>29.99</amount>
         <currency>USD</currency>
     </money>
 </assets>
with a Configuration mapped from:
<when parent.class="example.Assets">
     <when property="money"><!-- not a real property -->
         <choose getter="ExpansionGetter" property="money"
             marshaller="ExpansionMarshaller"/><!-- prefix="money" by default -->
         <!-- class="example.Assets" too.  To prevent subsequent confusion: -->
         <choose includeProperties=""/>
         <!-- This isn't necessary if an XML schema (or other Model) is used
              to constrain the XML, in which case Beck won't output nested money
              elements because the schema doesn't allow it.
           -->
     </when>
 </when>
 <when class="example.Assets">
     <choose includeProperties="money"/>
 </when>


Field Summary
 
Fields inherited from class com.openharbor.beck.get.DefaultGetter
log
 
Fields inherited from interface com.openharbor.beck.configure.Configurable
ATTRIBUTE, CLASS_IS_ARRAY, DIRECTION, ELEMENT, JAVA_TO_XML, NAMESPACE, NONE, PARENT_CLASS, PARENT_ELEMENT, PREDICATE, PREFIX, SCHEMA_LOCATION, TEXT, XML_TO_JAVA
 
Constructor Summary
ExpansionGetter()
           
 
Method Summary
 java.lang.Class getClass(java.lang.Object parent)
           
 java.util.Map getConfiguration()
           
 java.lang.String getName(java.lang.Class childClass)
           
 java.lang.Object getValue(java.lang.Object parent)
           
 void setConfiguration(java.util.Map configuration)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExpansionGetter

public ExpansionGetter()
Method Detail

getConfiguration

public java.util.Map getConfiguration()
Specified by:
getConfiguration in interface Configurable

setConfiguration

public void setConfiguration(java.util.Map configuration)
Specified by:
setConfiguration in interface Configurable

getName

public java.lang.String getName(java.lang.Class childClass)
Specified by:
getName in interface Getter
Returns:
the name of the object in the context of its parent or null to indicate that the object is anonymous (e.g. a collection member).

getClass

public java.lang.Class getClass(java.lang.Object parent)
Specified by:
getClass in interface Getter
Overrides:
getClass in class DefaultGetter

getValue

public java.lang.Object getValue(java.lang.Object parent)
Specified by:
getValue in interface Getter
Returns:
the object to which this get refers.