com.thoughtworks.xstream.io.xml
Class XmlFriendlyNameCoder

java.lang.Object
  extended by com.thoughtworks.xstream.io.xml.XmlFriendlyNameCoder
All Implemented Interfaces:
NameCoder, Cloneable
Direct Known Subclasses:
XmlFriendlyReplacer, XStream11NameCoder

public class XmlFriendlyNameCoder
extends Object
implements NameCoder, Cloneable

Encode and decode tag and attribute names in XML drivers.

This NameCoder is designed to ensure the correct encoding and decoding of names used for Java types and fields to XML tags and attribute names.

The default replacements are:

Since:
1.4
Author:
Jörg Schaible, Mauro Talevi, Tatu Saloranta, Michael Schnell
See Also:
XML 1.0 name definition, XML 1.1 name definition, Java identifier definition

Constructor Summary
XmlFriendlyNameCoder()
          Construct a new XmlFriendlyNameCoder.
XmlFriendlyNameCoder(String dollarReplacement, String escapeCharReplacement)
          Construct a new XmlFriendlyNameCoder with custom replacement strings for dollar and the escape character.
XmlFriendlyNameCoder(String dollarReplacement, String escapeCharReplacement, String hexPrefix)
          Construct a new XmlFriendlyNameCoder with custom replacement strings for dollar, the escape character and the prefix for hexadecimal encoding of invalid characters in XML names.
 
Method Summary
 Object clone()
           
 String decodeAttribute(String attributeName)
          Decode an attribute name to an object name.
 String decodeNode(String elementName)
          Decode a node name to an object name.
 String encodeAttribute(String name)
          Encode a meta-data name for an attribute in the target format.
 String encodeNode(String name)
          Encode an object name for a node in the target format.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlFriendlyNameCoder

public XmlFriendlyNameCoder()
Construct a new XmlFriendlyNameCoder.

Since:
1.4

XmlFriendlyNameCoder

public XmlFriendlyNameCoder(String dollarReplacement,
                            String escapeCharReplacement)
Construct a new XmlFriendlyNameCoder with custom replacement strings for dollar and the escape character.

Parameters:
dollarReplacement -
escapeCharReplacement -
Since:
1.4

XmlFriendlyNameCoder

public XmlFriendlyNameCoder(String dollarReplacement,
                            String escapeCharReplacement,
                            String hexPrefix)
Construct a new XmlFriendlyNameCoder with custom replacement strings for dollar, the escape character and the prefix for hexadecimal encoding of invalid characters in XML names.

Parameters:
dollarReplacement -
escapeCharReplacement -
Since:
1.4
Method Detail

decodeAttribute

public String decodeAttribute(String attributeName)
Decode an attribute name to an object name.

Specified by:
decodeAttribute in interface NameCoder
Parameters:
attributeName - the name of the attribute
Returns:
the name of the meta-data

decodeNode

public String decodeNode(String elementName)
Decode a node name to an object name.

Specified by:
decodeNode in interface NameCoder
Parameters:
elementName - the name of the node
Returns:
the name of the object

encodeAttribute

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

Specified by:
encodeAttribute in interface NameCoder
Parameters:
name - the name of the meta-data
Returns:
the attribute name in the target format

encodeNode

public String encodeNode(String name)
Encode an object name for a node in the target format.

Specified by:
encodeNode in interface NameCoder
Parameters:
name - the name of the object data
Returns:
the node name in the target format

clone

public Object clone()
Overrides:
clone in class Object


Copyright © 2004-2014 XStream. All Rights Reserved.