ModeShape Distribution 3.0.0.Beta4

Class XmlNameEncoder

  extended by org.modeshape.common.text.XmlNameEncoder
All Implemented Interfaces:
TextDecoder, TextEncoder

public class XmlNameEncoder
extends Object
implements TextDecoder, TextEncoder

An encoder and decoder for XML element and attribute names.

Any UTF-16 unicode character that is not a valid XML name character according to the World Wide Web Consortium (W3C) Extensible Markup Language (XML) 1.0 (Fourth Edition) Recommendation is escaped as _xHHHH_, where HHHH stands for the four-digit hexadecimal UTF-16 unicode value for the character in the most significant bit first order. For example, the name "Customer_ID" is encoded as "Customer_x0020_ID".

Decoding transforms every _xHHHH_ encoding sequences back into the UTF-16 character. Note that decoding can be safely done on any XML name, even if the name does not contain any encoded sequences.

Constructor Summary
Method Summary
 String decode(String encodedText)
          Return the decoded version of an encoded string
 String encode(String text)
          Returns the encoded version of a string.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public XmlNameEncoder()
Method Detail


public String decode(String encodedText)
Return the decoded version of an encoded string

Specified by:
decode in interface TextDecoder
encodedText - the encoded text
the unecoded form of the text, or null if the supplied node name is also null
See Also:


public String encode(String text)
Returns the encoded version of a string.

Specified by:
encode in interface TextEncoder
text - the text with characters that are to be encoded.
the text with the characters encoded as required, or null if the supplied text is null
See Also:

ModeShape Distribution 3.0.0.Beta4

Copyright © 2008-2012 JBoss, a division of Red Hat. All Rights Reserved.