Class StaticNameCoder
- java.lang.Object
-
- com.thoughtworks.xstream.io.naming.StaticNameCoder
-
- All Implemented Interfaces:
NameCoder
public class StaticNameCoder extends java.lang.Object implements NameCoder
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.
- Since:
- 1.4
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Mapattribute2Javaprivate java.util.Mapjava2Attributeprivate java.util.Mapjava2Nodeprivate java.util.Mapnode2Java
-
Constructor Summary
Constructors Constructor Description StaticNameCoder(java.util.Map java2Node, java.util.Map java2Attribute)Construct a StaticNameCoder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringdecodeAttribute(java.lang.String attributeName)Decode an attribute name to an object name.java.lang.StringdecodeNode(java.lang.String nodeName)Decode a node name to an object name.java.lang.StringencodeAttribute(java.lang.String name)Encode a meta-data name for an attribute in the target format.java.lang.StringencodeNode(java.lang.String name)Encode an object name for a node in the target format.private java.util.MapinvertMap(java.util.Map map)private java.lang.ObjectreadResolve()
-
-
-
Method Detail
-
decodeAttribute
public java.lang.String decodeAttribute(java.lang.String attributeName)
Decode an attribute name to an object name.- Specified by:
decodeAttributein interfaceNameCoder- Parameters:
attributeName- the name of the attribute- Returns:
- the name of the meta-data
-
decodeNode
public java.lang.String decodeNode(java.lang.String nodeName)
Decode a node name to an object name.- Specified by:
decodeNodein interfaceNameCoder- Parameters:
nodeName- the name of the node- Returns:
- the name of the object
-
encodeAttribute
public java.lang.String encodeAttribute(java.lang.String name)
Encode a meta-data name for an attribute in the target format.- Specified by:
encodeAttributein interfaceNameCoder- Parameters:
name- the name of the meta-data- Returns:
- the attribute name in the target format
-
encodeNode
public java.lang.String encodeNode(java.lang.String name)
Encode an object name for a node in the target format.- Specified by:
encodeNodein interfaceNameCoder- Parameters:
name- the name of the object data- Returns:
- the node name in the target format
-
readResolve
private java.lang.Object readResolve()
-
invertMap
private java.util.Map invertMap(java.util.Map map)
-
-