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

java.lang.Object
  extended by org.apache.shindig.protocol.conversion.xstream.ClassFieldMapping

public class ClassFieldMapping
extends Object

This represents the mapping between a class and a field, potentially with a parent element. It is used to define the element names that are used to serialize the contents of a class. eg

 <outerobject>
 <listcontainer>
    <listelement>
       <objectcontent>
    </listelement>
 </listcontainer>
 ...
 </outerobject>
 
or (not currently used in OS)
 <person>
    <emails>
       <email>
          <type></type>
          <value></value>
       </email>
       ...
    </emails>
    ...
 </person>
 
For a more compact mapping ItemFieldMapping.


Constructor Summary
ClassFieldMapping(String elementName, Class<?> mappedClazz)
          Create a simple element class mapping, applicable to all parent elements.
ClassFieldMapping(String parentName, String elementName, Class<?> mappedClazz)
          Create a element class mapping, that only applies to one parent element name.
 
Method Summary
 String getElementName()
           
 Class<?> getMappedClass()
           
 boolean matches(String parent, Class<?> type)
          Does this ClassFieldMapping match the supplied parent and type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassFieldMapping

public ClassFieldMapping(String elementName,
                         Class<?> mappedClazz)
Create a simple element class mapping, applicable to all parent elements.

Parameters:
elementName - the name of the element
mappedClazz - the class to map to the name of the element

ClassFieldMapping

public ClassFieldMapping(String parentName,
                         String elementName,
                         Class<?> mappedClazz)
Create a element class mapping, that only applies to one parent element name.

Parameters:
parentName - the name of the parent element that this mapping applies to
elementName - the name of the element
mappedClazz - the class to map to the name of the element
Method Detail

getElementName

public String getElementName()
Returns:
get the element name.

getMappedClass

public Class<?> getMappedClass()
Returns:
get the mapped class.

matches

public boolean matches(String parent,
                       Class<?> type)
Does this ClassFieldMapping match the supplied parent and type.

Parameters:
parent - the parent element, which may be null
type - the type of the field being stored
Returns:
true if this mapping is a match for the combination


Copyright © 2007-2012. All Rights Reserved.