org.apache.shindig.protocol.conversion.xstream
Class ImplicitCollectionFieldMapping

java.lang.Object
  extended by org.apache.shindig.protocol.conversion.xstream.ImplicitCollectionFieldMapping
All Implemented Interfaces:
com.thoughtworks.xstream.mapper.Mapper.ImplicitCollectionMapping

public class ImplicitCollectionFieldMapping
extends Object
implements com.thoughtworks.xstream.mapper.Mapper.ImplicitCollectionMapping

ItemFieldMapping defines a mapping of a class within a class to an element name. Where classes are tested, the must implement or extend the specified classes, unlike the standard behaviour of XStream they dont need to be the classes in question.

The structure is used for implicit collections of the form *

 <outerobject>
    <listelement>
       <objectcontent>
    </listelement>
    <listelement>
       <objectcontent>
    </listelement>
 ...
 </outerobject>
 

or

 <person>
     <emails>
        <type></type>
        <value></value>
     </emails>
     <emails>
        <type></type>
        <value></value>
     </emails>
     <emails>
        <type></type>
        <value></value>
     </emails>
     ...
 </person>
 

would be specified with NewItemFieldMapping(Person.class, "emails", ListField.class, "emails");


Constructor Summary
ImplicitCollectionFieldMapping(Class<?> definedIn, String fieldName, Class<?> itemType, String itemFieldName)
          Create a Item Field Mapping object specifying that where the class itemType appears in the Class definedIn, the elementName should be used for the Element Name.
 
Method Summary
 String getFieldName()
           
 String getItemFieldName()
           
 Class<?> getItemType()
           
 boolean matches(Class<?> definedIn, Class<?> itemType)
          Does this ItemFieldMapping match the supplied classes.
 boolean matches(Class<?> definedIn, String fieldName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImplicitCollectionFieldMapping

public ImplicitCollectionFieldMapping(Class<?> definedIn,
                                      String fieldName,
                                      Class<?> itemType,
                                      String itemFieldName)
Create a Item Field Mapping object specifying that where the class itemType appears in the Class definedIn, the elementName should be used for the Element Name.

Parameters:
definedIn - the class which contains the method
fieldName - the name of the method/field in the class.
itemType - the type of the method/field in the class.
itemFieldName - the name of element in the xml
Method Detail

matches

public boolean matches(Class<?> definedIn,
                       Class<?> itemType)
Does this ItemFieldMapping match the supplied classes.

Parameters:
definedIn - the class that the target test class is defiend in, this is a real class
itemType - the target class, the real class
Returns:
true if the defiendIn class implements the defiendIn class of this ItemFieldMapping and the itemType class implements the itemType class of this ItemFieldMapping.

matches

public boolean matches(Class<?> definedIn,
                       String fieldName)

getFieldName

public String getFieldName()
Specified by:
getFieldName in interface com.thoughtworks.xstream.mapper.Mapper.ImplicitCollectionMapping
Returns:

getItemFieldName

public String getItemFieldName()
Specified by:
getItemFieldName in interface com.thoughtworks.xstream.mapper.Mapper.ImplicitCollectionMapping
Returns:

getItemType

public Class<?> getItemType()
Specified by:
getItemType in interface com.thoughtworks.xstream.mapper.Mapper.ImplicitCollectionMapping
Returns:


Copyright © 2007-2012. All Rights Reserved.