com.thoughtworks.xstream.mapper
Class DefaultMapper

java.lang.Object
  extended by com.thoughtworks.xstream.mapper.DefaultMapper
All Implemented Interfaces:
Mapper

public class DefaultMapper
extends java.lang.Object
implements Mapper

Default mapper implementation with 'vanilla' functionality. To build up the functionality required, wrap this mapper with other mapper implementations.

Author:
Joe Walnes

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.thoughtworks.xstream.mapper.Mapper
Mapper.ImplicitCollectionMapping, Mapper.Null
 
Constructor Summary
DefaultMapper(java.lang.ClassLoader classLoader)
           
DefaultMapper(java.lang.ClassLoader classLoader, java.lang.String classAttributeIdentifier)
          Deprecated. since 1.2, use XStream.aliasAttrbute() for a different attribute name.
 
Method Summary
 java.lang.String aliasForAttribute(java.lang.String attribute)
          Get the alias for an attrbute's name.
 java.lang.String attributeForAlias(java.lang.String alias)
          Get the attribut's name for an alias.
 java.lang.String attributeForClassDefiningField()
          Deprecated. since 1.2, use aliasForAttribute instead.
 java.lang.String attributeForEnumType()
          Deprecated. since 1.2, use aliasForAttribute instead.
 java.lang.String attributeForImplementationClass()
          Deprecated. since 1.2, use aliasForAttribute instead.
 java.lang.String attributeForReadResolveField()
          Deprecated. since 1.2, use aliasForAttribute instead.
 java.lang.Class defaultImplementationOf(java.lang.Class type)
           
 SingleValueConverter getConverterFromAttribute(java.lang.String name)
           
 SingleValueConverter getConverterFromItemType(java.lang.Class type)
           
 SingleValueConverter getConverterFromItemType(java.lang.String fieldName, java.lang.Class type)
           
 java.lang.String getFieldNameForItemTypeAndName(java.lang.Class definedIn, java.lang.Class itemType, java.lang.String itemFieldName)
          Get the name of the field that acts as the default collection for an object, or return null if there is none.
 Mapper.ImplicitCollectionMapping getImplicitCollectionDefForFieldName(java.lang.Class itemType, java.lang.String fieldName)
           
 java.lang.Class getItemTypeForItemFieldName(java.lang.Class definedIn, java.lang.String itemFieldName)
           
 boolean isImmutableValueType(java.lang.Class type)
          Whether this type is a simple immutable value (int, boolean, String, URL, etc.
 Mapper lookupMapperOfType(java.lang.Class type)
           
 java.lang.String lookupName(java.lang.Class type)
           
 java.lang.Class lookupType(java.lang.String elementName)
           
 java.lang.Class realClass(java.lang.String elementName)
          How a serialized class representation should be mapped back to a real class.
 java.lang.String realMember(java.lang.Class type, java.lang.String serialized)
          How a serialized member representation should be mapped back to a real member.
 java.lang.String serializedClass(java.lang.Class type)
          How a class name should be represented in its serialized form.
 java.lang.String serializedMember(java.lang.Class type, java.lang.String memberName)
          How a class member should be represented in its serialized form.
 boolean shouldSerializeMember(java.lang.Class definedIn, java.lang.String fieldName)
          Determine whether a specific member should be serialized.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultMapper

public DefaultMapper(java.lang.ClassLoader classLoader)

DefaultMapper

public DefaultMapper(java.lang.ClassLoader classLoader,
                     java.lang.String classAttributeIdentifier)
Deprecated. since 1.2, use XStream.aliasAttrbute() for a different attribute name.

Method Detail

serializedClass

public java.lang.String serializedClass(java.lang.Class type)
Description copied from interface: Mapper
How a class name should be represented in its serialized form.

Specified by:
serializedClass in interface Mapper

realClass

public java.lang.Class realClass(java.lang.String elementName)
Description copied from interface: Mapper
How a serialized class representation should be mapped back to a real class.

Specified by:
realClass in interface Mapper

defaultImplementationOf

public java.lang.Class defaultImplementationOf(java.lang.Class type)
Specified by:
defaultImplementationOf in interface Mapper

attributeForClassDefiningField

public java.lang.String attributeForClassDefiningField()
Deprecated. since 1.2, use aliasForAttribute instead.

Specified by:
attributeForClassDefiningField in interface Mapper

attributeForReadResolveField

public java.lang.String attributeForReadResolveField()
Deprecated. since 1.2, use aliasForAttribute instead.

Specified by:
attributeForReadResolveField in interface Mapper

attributeForEnumType

public java.lang.String attributeForEnumType()
Deprecated. since 1.2, use aliasForAttribute instead.

Specified by:
attributeForEnumType in interface Mapper

attributeForImplementationClass

public java.lang.String attributeForImplementationClass()
Deprecated. since 1.2, use aliasForAttribute instead.

Specified by:
attributeForImplementationClass in interface Mapper

aliasForAttribute

public java.lang.String aliasForAttribute(java.lang.String attribute)
Description copied from interface: Mapper
Get the alias for an attrbute's name.

Specified by:
aliasForAttribute in interface Mapper
Parameters:
attribute - the attribute
Returns:
the alias

attributeForAlias

public java.lang.String attributeForAlias(java.lang.String alias)
Description copied from interface: Mapper
Get the attribut's name for an alias.

Specified by:
attributeForAlias in interface Mapper
Parameters:
alias - the alias
Returns:
the attribute's name

isImmutableValueType

public boolean isImmutableValueType(java.lang.Class type)
Description copied from interface: Mapper
Whether this type is a simple immutable value (int, boolean, String, URL, etc. Immutable types will be repeatedly written in the serialized stream, instead of using object references.

Specified by:
isImmutableValueType in interface Mapper

getFieldNameForItemTypeAndName

public java.lang.String getFieldNameForItemTypeAndName(java.lang.Class definedIn,
                                                       java.lang.Class itemType,
                                                       java.lang.String itemFieldName)
Description copied from interface: Mapper
Get the name of the field that acts as the default collection for an object, or return null if there is none.

Specified by:
getFieldNameForItemTypeAndName in interface Mapper
Parameters:
definedIn - owning type
itemType - item type
itemFieldName - optional item element name

getItemTypeForItemFieldName

public java.lang.Class getItemTypeForItemFieldName(java.lang.Class definedIn,
                                                   java.lang.String itemFieldName)
Specified by:
getItemTypeForItemFieldName in interface Mapper

getImplicitCollectionDefForFieldName

public Mapper.ImplicitCollectionMapping getImplicitCollectionDefForFieldName(java.lang.Class itemType,
                                                                             java.lang.String fieldName)
Specified by:
getImplicitCollectionDefForFieldName in interface Mapper

shouldSerializeMember

public boolean shouldSerializeMember(java.lang.Class definedIn,
                                     java.lang.String fieldName)
Description copied from interface: Mapper
Determine whether a specific member should be serialized.

Specified by:
shouldSerializeMember in interface Mapper

lookupName

public java.lang.String lookupName(java.lang.Class type)

lookupType

public java.lang.Class lookupType(java.lang.String elementName)

serializedMember

public java.lang.String serializedMember(java.lang.Class type,
                                         java.lang.String memberName)
Description copied from interface: Mapper
How a class member should be represented in its serialized form.

Specified by:
serializedMember in interface Mapper

realMember

public java.lang.String realMember(java.lang.Class type,
                                   java.lang.String serialized)
Description copied from interface: Mapper
How a serialized member representation should be mapped back to a real member.

Specified by:
realMember in interface Mapper

getConverterFromAttribute

public SingleValueConverter getConverterFromAttribute(java.lang.String name)
Specified by:
getConverterFromAttribute in interface Mapper

getConverterFromItemType

public SingleValueConverter getConverterFromItemType(java.lang.String fieldName,
                                                     java.lang.Class type)
Specified by:
getConverterFromItemType in interface Mapper

getConverterFromItemType

public SingleValueConverter getConverterFromItemType(java.lang.Class type)
Specified by:
getConverterFromItemType in interface Mapper

lookupMapperOfType

public Mapper lookupMapperOfType(java.lang.Class type)
Specified by:
lookupMapperOfType in interface Mapper


Joe Walnes, http://xstream.codehaus.org/