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

public Interface NameCoder

Known Direct Implementers
com.thoughtworks.xstream.io.naming.NameCoderWrapper, com.thoughtworks.xstream.io.naming.NoNameCoder, com.thoughtworks.xstream.io.naming.StaticNameCoder, com.thoughtworks.xstream.io.xml.XmlFriendlyNameCoder

Coder between names in the object graph and names of a target format.

The names form the object graph are typically names generated from Java identifiers (Java types or field members), but some names may also contain a minus sign. However, the original name might have already been aliased, so a wider range of characters can occur.

The target names should satisfy the syntax of the target format. Transforming Java objects to XML this affects names that contain or even start with a dollar sign. Such names violate the XML specification.

By default all names from the object graph are used as node names in the target format. Meta-data that is necessary to unmarshal the object again is typically written as attribute. Since such attributes might be represented differently in the target format, the NameCoder distinguishes between the names used for meta-data elements and the ones for the object data. The names in the target format might even have to follow a different syntax. Remember, that XStream can be easily configured to write also object data as attributes.

Note that the instance of a NameCoder should be either thread-safe or implement Cloneable.

Author
Jörg Schaible
Since
1.4

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

the name of the meta-data
decodeAttribute
(String
the name of the attribute
attributeName
)

Decode an attribute name to an object name.

public String

Returns:

the name of the object
decodeNode
(String
the name of the node
nodeName
)

Decode a node name to an object name.

public String

Returns:

the attribute name in the target format
encodeAttribute
(String
the name of the meta-data
name
)

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

public String

Returns:

the node name in the target format
encodeNode
(String
the name of the object data
name
)

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

Method Detail

decodeAttributeback to summary
public String decodeAttribute(String attributeName)

Decode an attribute name to an object name.

Parameters
attributeName:String

the name of the attribute

Returns:String

the name of the meta-data

Since
1.4
decodeNodeback to summary
public String decodeNode(String nodeName)

Decode a node name to an object name.

Parameters
nodeName:String

the name of the node

Returns:String

the name of the object

Since
1.4
encodeAttributeback to summary
public String encodeAttribute(String name)

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

Since
1.4
encodeNodeback to summary
public String encodeNode(String name)

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

Since
1.4