public final class XMLIndenter extends org.xml.sax.helpers.DefaultHandler implements ContentHandler
Note: This implementation is not namespace aware, and will not handle entities other than &, <, > or ".
| Modifier and Type | Method and Description |
|---|---|
void |
characters(char[] ch,
int position,
int offset)
Prints the characters.
|
void |
endElement(String uri,
String localName,
String qName) |
void |
ignorableWhitespace(char[] ch,
int position,
int offset)
Does nothing.
|
static void |
indent(Reader r,
Writer w)
Indents the given XML String.
|
static String |
indent(String xml)
Indents the given XML String.
|
static boolean |
indentSilent(Reader r,
Writer w)
Indents the given XML String.
|
static String |
indentSilent(String xml)
Indents the given XML String.
|
void |
startElement(String uri,
String localName,
String qName,
Attributes atts) |
endDocument, endPrefixMapping, error, fatalError, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warningclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitendDocument, endPrefixMapping, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startPrefixMappingpublic void startElement(String uri, String localName, String qName, Attributes atts)
startElement in interface ContentHandlerstartElement in class org.xml.sax.helpers.DefaultHandlerpublic void endElement(String uri, String localName, String qName)
endElement in interface ContentHandlerendElement in class org.xml.sax.helpers.DefaultHandlerpublic void characters(char[] ch,
int position,
int offset)
characters in interface ContentHandlercharacters in class org.xml.sax.helpers.DefaultHandlerpublic void ignorableWhitespace(char[] ch,
int position,
int offset)
ignorableWhitespace in interface ContentHandlerignorableWhitespace in class org.xml.sax.helpers.DefaultHandlerpublic static String indent(String xml) throws SAXException, IOException, ParserConfigurationException
xml - The XML string to indentIOException - If an IOException occurs.SAXException - If the XML is not well-formed.ParserConfigurationException - If the parser could not be configuredpublic static void indent(Reader r, Writer w) throws SAXException, IOException, ParserConfigurationException
r - A reader on XML dataw - A writer for the indented XMLIOException - If an IOException occurs.SAXException - If the XML is not well-formed.ParserConfigurationException - If the parser could not be configuredpublic static String indentSilent(String xml)
xml - The XML string to indentnull if an error occurred.public static boolean indentSilent(Reader r, Writer w)
This method does not throw any exception out of convenience, instead it returns a
boolean value to indicate whether the XML indenting was performed succesfully.
r - A reader on XML dataw - A writer for the indented XMLtrue if the operation was successful, false if an error
occurred.Copyright © 2007-2022. All Rights Reserved.