|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.xml.sax.helpers.DefaultHandler
com.topologi.diffx.xml.XMLIndenter
public final class XMLIndenter
A class to indent automatically some XML data.
Note: This implementation is not namespace aware, and will not handle entities other than &, <, > or ".
Method Summary | |
---|---|
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)
|
Methods inherited from class org.xml.sax.helpers.DefaultHandler |
---|
endDocument, endPrefixMapping, error, fatalError, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.xml.sax.ContentHandler |
---|
endDocument, endPrefixMapping, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping |
Method Detail |
---|
public void startElement(String uri, String localName, String qName, Attributes atts)
startElement
in interface ContentHandler
startElement
in class DefaultHandler
public void endElement(String uri, String localName, String qName)
endElement
in interface ContentHandler
endElement
in class DefaultHandler
public void characters(char[] ch, int position, int offset)
characters
in interface ContentHandler
characters
in class DefaultHandler
public void ignorableWhitespace(char[] ch, int position, int offset)
ignorableWhitespace
in interface ContentHandler
ignorableWhitespace
in class DefaultHandler
public static String indent(String xml) throws SAXException, IOException, ParserConfigurationException
xml
- The XML string to indent
IOException
- 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 XML
IOException
- 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 indent
null
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 XML
true
if the operation was successful, false
if an error
occurred.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |