hmi.xml
Class CharDataConversion
java.lang.Object
hmi.xml.CharDataConversion
public class CharDataConversion
- extends Object
CharDataConversion has methods to translate Strings (back and forth)
into XML style CharData. The latter refers to the character data that occurs between
XML tags: CharData , or as Attribute Value strings of the form : "text"
or 'text'. Such character data and string texts cannot include the '<' and '&,
characters, and, in the case of text strings, it cannot contain the
string quote or apostrophe character. Moreover, XML CharData cannot include the pattern "]]>".
CharDataConversion takes care of this: selected characters are replaced by XML entity references,
such as "<", representing a "<" character. Unmarshalling carries out the
reverse translation. Marshalling performs the following translations:
'<' to "<", '>' to ">", '&' to "&", '"' to """, '\'' to "'".
(Note that the sequence of the form "]]>" is therefore translated to "]]>").
- Author:
- Job Zwiers
adapted from old parlevink packages.
|
Method Summary |
static String |
decode(String value)
converts the encoded XML representation
to the 'normal' String representation. |
static String |
encode(String value)
converts the String representation
to the encoded XML representation. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CharDataConversion
public CharDataConversion()
encode
public static String encode(String value)
- converts the String representation
to the encoded XML representation.
The latter uses XML entity references: "<"; for '<', ">" for '>', and "&" for '&'
""" for '"', and "'" for '\''.
The resulting external String can be safely used as CharData or attribute value
in an XML text.
decode
public static String decode(String value)
- converts the encoded XML representation
to the 'normal' String representation.
The former uses "<"; for '<', ">" for '>', and "&" for '&';
""" for '"', and "'" for '\''.
these XML entity references are translated back to ordinary characters.