public class SafeContentHandler extends ContentHandlerDecorator
characters(char[], int, int) or
ignorableWhitespace(char[], int, int)) passed to the decorated
content handler contain only valid XML characters. All invalid characters
are replaced with the Unicode replacement character U+FFFD (though a
subclass may change this by overriding the writeReplacement(Output) method).
The XML standard defines the following Unicode character ranges as valid XML characters:
#x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
Note that currently this class only detects those invalid characters whose UTF-16 representation fits a single char. Also, this class does not ensure that the UTF-16 encoding of incoming characters is correct.
| Constructor and Description |
|---|
SafeContentHandler(ContentHandler handler) |
| Modifier and Type | Method and Description |
|---|---|
void |
characters(char[] ch,
int start,
int length) |
void |
endDocument() |
void |
endElement(String uri,
String localName,
String name) |
void |
ignorableWhitespace(char[] ch,
int start,
int length) |
void |
startElement(String uri,
String localName,
String name,
Attributes atts) |
endPrefixMapping, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, toStringerror, fatalError, notationDecl, resolveEntity, unparsedEntityDecl, warningpublic SafeContentHandler(ContentHandler handler)
public void startElement(String uri, String localName, String name, Attributes atts) throws SAXException
startElement in interface ContentHandlerstartElement in class ContentHandlerDecoratorSAXExceptionpublic void endElement(String uri, String localName, String name) throws SAXException
endElement in interface ContentHandlerendElement in class ContentHandlerDecoratorSAXExceptionpublic void endDocument()
throws SAXException
endDocument in interface ContentHandlerendDocument in class ContentHandlerDecoratorSAXExceptionpublic void characters(char[] ch,
int start,
int length)
throws SAXException
characters in interface ContentHandlercharacters in class ContentHandlerDecoratorSAXExceptionpublic void ignorableWhitespace(char[] ch,
int start,
int length)
throws SAXException
ignorableWhitespace in interface ContentHandlerignorableWhitespace in class ContentHandlerDecoratorSAXExceptionCopyright © 2010 - 2020 Adobe. All Rights Reserved