Package org.apache.xmlbeans
Class XmlOptionCharEscapeMap
- java.lang.Object
-
- org.apache.xmlbeans.XmlOptionCharEscapeMap
-
public class XmlOptionCharEscapeMap extends java.lang.Object
Corresponds to the Saver and XmlOptions.This class is used to set up a map containing characters to be escaped. Characters can be escaped as hex, decimal or as a predefined entity (this latter option applies only to the 5 characters defined as predefined entities in the XML Spec).
-
For example:
XmlOptionCharEscapeMap escapes = new XmlOptionCharEscapeMap(); escapes.addMapping('A', XmlOptionCharEscapeMap.HEXADECIMAL); escapes.addMapping('B', XmlOptionCharEscapeMap.DECIMAL); escapes.addMapping('>', XmlOptionCharEscapeMap.PREDEF_ENTITY); XmlOptions opts = new XmlOptions(); opts.setSaveSubstituteCharacters(escapes); System.out.println(myXml.xmlText(opts)); will result in: A being printed as A B being printed as B > being printed as >
-
-
Field Summary
Fields Modifier and Type Field Description static int
DECIMAL
static int
HEXADECIMAL
static int
PREDEF_ENTITY
-
Constructor Summary
Constructors Constructor Description XmlOptionCharEscapeMap()
Construct a new XmlOptionCharEncoder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addMapping(char ch, int mode)
set up this character to be escaped in output documents according to the given modevoid
addMappings(char ch1, char ch2, int mode)
set up this contiguous set of characters to be escaped in output documents according to the given modeboolean
containsChar(char ch)
java.lang.String
getEscapedString(char ch)
returns the escaped String for the character
-
-
-
Field Detail
-
PREDEF_ENTITY
public static final int PREDEF_ENTITY
- See Also:
- Constant Field Values
-
DECIMAL
public static final int DECIMAL
- See Also:
- Constant Field Values
-
HEXADECIMAL
public static final int HEXADECIMAL
- See Also:
- Constant Field Values
-
-
Method Detail
-
containsChar
public boolean containsChar(char ch)
- Returns:
- whether a character encoding exists for this character
-
addMapping
public void addMapping(char ch, int mode) throws XmlException
set up this character to be escaped in output documents according to the given mode- Throws:
XmlException
-
addMappings
public void addMappings(char ch1, char ch2, int mode) throws XmlException
set up this contiguous set of characters to be escaped in output documents according to the given mode- Throws:
XmlException
-
getEscapedString
public java.lang.String getEscapedString(char ch)
returns the escaped String for the character
-
-