Top Description Fields Constructors Methods
com.thoughtworks.xstream.io.naming

public Class StaticNameCoder

extends Object
implements NameCoder
Class Inheritance
All Implemented Interfaces
com.thoughtworks.xstream.io.naming.NameCoder
Imports
java.util.HashMap, .Iterator, .Map

A NameCoder that encodes and decodes names based on a map.

The provided map should contain a mapping between the name of the Java type or field to the proper element in the target format. If a name cannot be found in the map, it is assumed not to be mapped at all. Note that the values of the map should be unique also, otherwise the decoding will produce wrong results.

Author
Jörg Schaible
Since
1.4

Field Summary

Modifier and TypeField and Description
private transient Map<K, V>
private final Map<K, V>
private final Map<K, V>
private transient Map<K, V>

Constructor Summary

AccessConstructor and Description
public
StaticNameCoder(Map<K, V>
mapping of Java names to nodes
java2Node
,
Map<K, V>
mapping of Java names to attributes
java2Attribute
)

Construct a StaticNameCoder.

Method Summary

Modifier and TypeMethod and Description
public String
decodeAttribute(String
the name of the attribute
attributeName
)

Implements com.thoughtworks.xstream.io.naming.NameCoder.decodeAttribute.

Decode an attribute name to an object name.
public String
decodeNode(String
the name of the node
nodeName
)

Implements com.thoughtworks.xstream.io.naming.NameCoder.decodeNode.

Decode a node name to an object name.
public String
encodeAttribute(String
the name of the meta-data
name
)

Implements com.thoughtworks.xstream.io.naming.NameCoder.encodeAttribute.

Encode a meta-data name for an attribute in the target format.
public String
encodeNode(String
the name of the object data
name
)

Implements com.thoughtworks.xstream.io.naming.NameCoder.encodeNode.

Encode an object name for a node in the target format.
private Map<K, V>
invertMap(Map<K, V> map)

private Object
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

attribute2Javaback to summary
private transient Map<K, V> attribute2Java
java2Attributeback to summary
private final Map<K, V> java2Attribute
java2Nodeback to summary
private final Map<K, V> java2Node
node2Javaback to summary
private transient Map<K, V> node2Java

Constructor Detail

StaticNameCoderback to summary
public StaticNameCoder(Map<K, V> java2Node, Map<K, V> java2Attribute)

Construct a StaticNameCoder.

Parameters
java2Node:Map<K, V>

mapping of Java names to nodes

java2Attribute:Map<K, V>

mapping of Java names to attributes

Since
1.4

Method Detail

decodeAttributeback to summary
public String decodeAttribute(String attributeName)

Implements com.thoughtworks.xstream.io.naming.NameCoder.decodeAttribute.

Doc from com.thoughtworks.xstream.io.naming.NameCoder.decodeAttribute.

Decode an attribute name to an object name.

Parameters
attributeName:String

the name of the attribute

Returns:String

the name of the meta-data

decodeNodeback to summary
public String decodeNode(String nodeName)

Implements com.thoughtworks.xstream.io.naming.NameCoder.decodeNode.

Doc from com.thoughtworks.xstream.io.naming.NameCoder.decodeNode.

Decode a node name to an object name.

Parameters
nodeName:String

the name of the node

Returns:String

the name of the object

encodeAttributeback to summary
public String encodeAttribute(String name)

Implements com.thoughtworks.xstream.io.naming.NameCoder.encodeAttribute.

Doc from com.thoughtworks.xstream.io.naming.NameCoder.encodeAttribute.

Encode a meta-data name for an attribute in the target format.

Parameters
name:String

the name of the meta-data

Returns:String

the attribute name in the target format

encodeNodeback to summary
public String encodeNode(String name)

Implements com.thoughtworks.xstream.io.naming.NameCoder.encodeNode.

Doc from com.thoughtworks.xstream.io.naming.NameCoder.encodeNode.

Encode an object name for a node in the target format.

Parameters
name:String

the name of the object data

Returns:String

the node name in the target format

invertMapback to summary
private Map<K, V> invertMap(Map<K, V> map)
readResolveback to summary
private Object readResolve()