|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.xml.sax.helpers.DefaultHandler
com.adventnet.utilities.xml.indenter.XMLIndenter
public class XMLIndenter
2 constructors Takes a file name as input and fills the StringBuffer sb . Returns the indented string as output through getData() method The policy of indentation is by default 4 spaces This class uses com.sun.xml.parser.Parser and requires the package org.xml.sax package This will not retain any comments or anything else. It only parses and indents pure XML rest every thing is just removed.
| Field Summary | |
|---|---|
(package private) int |
level
|
(package private) javax.xml.parsers.SAXParser |
parser
|
(package private) java.lang.StringBuffer |
sb
|
(package private) java.lang.String |
spacePerLevel
|
(package private) org.xml.sax.XMLReader |
xmlReader
|
| Constructor Summary | |
|---|---|
XMLIndenter()
Takes a file name as input and fills the StringBuffer sb . |
|
| Method Summary | |
|---|---|
void |
characters(char[] ch,
int start,
int length)
|
void |
endElement(java.lang.String uri,
java.lang.String localName,
java.lang.String name)
|
void |
error(org.xml.sax.SAXParseException sax)
|
static java.lang.String |
escape(java.lang.String text_pm)
This function add the escaoe characters for the XML file KEY < < > > " " ' ' |
void |
fatalError(org.xml.sax.SAXParseException sax)
|
java.lang.String |
getData()
|
void |
ignorableWhitespace(char[] ch,
int start,
int length)
|
static void |
indentFile(java.io.File file)
|
static java.lang.String |
indentString(java.lang.Object ob)
|
static void |
main(java.lang.String[] s)
|
void |
processingInstruction(java.lang.String target,
java.lang.String data)
Not sure if this function is implemented correctly |
void |
setNewLineForCloseTag(java.lang.String s)
Set this before start is called . |
void |
setSpacePerLevel(java.lang.String s)
Set the space before start is called . |
void |
start(java.io.File file)
User defined method to start the Indenter. |
java.lang.String |
start(java.lang.Object fileContents)
User defined method to start the Indenter. |
void |
startElement(java.lang.String uriName,
java.lang.String name,
java.lang.String rawName,
org.xml.sax.Attributes atts)
|
java.lang.String |
toURL(java.io.File f)
|
void |
warning(org.xml.sax.SAXParseException sax)
|
| Methods inherited from class org.xml.sax.helpers.DefaultHandler |
|---|
endDocument, endPrefixMapping, notationDecl, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
java.lang.StringBuffer sb
int level
java.lang.String spacePerLevel
javax.xml.parsers.SAXParser parser
org.xml.sax.XMLReader xmlReader
| Constructor Detail |
|---|
public XMLIndenter()
throws javax.xml.parsers.ParserConfigurationException,
org.xml.sax.SAXException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException| Method Detail |
|---|
public java.lang.String start(java.lang.Object fileContents)
throws java.io.IOException,
org.xml.sax.SAXException,
javax.xml.parsers.ParserConfigurationException
java.io.IOException
org.xml.sax.SAXException
javax.xml.parsers.ParserConfigurationException
public void start(java.io.File file)
throws java.io.IOException,
java.io.FileNotFoundException,
org.xml.sax.SAXException,
java.net.MalformedURLException,
javax.xml.parsers.ParserConfigurationException
java.io.IOException
java.io.FileNotFoundException
org.xml.sax.SAXException
java.net.MalformedURLException
javax.xml.parsers.ParserConfigurationException
public java.lang.String toURL(java.io.File f)
throws java.net.MalformedURLException
java.net.MalformedURLException
public static void indentFile(java.io.File file)
throws java.lang.Exception
java.lang.Exception
public static java.lang.String indentString(java.lang.Object ob)
throws java.lang.Exception
java.lang.Exception
public void startElement(java.lang.String uriName,
java.lang.String name,
java.lang.String rawName,
org.xml.sax.Attributes atts)
throws org.xml.sax.SAXException
startElement in interface org.xml.sax.ContentHandlerstartElement in class org.xml.sax.helpers.DefaultHandlerorg.xml.sax.SAXException
public void characters(char[] ch,
int start,
int length)
throws org.xml.sax.SAXException
characters in interface org.xml.sax.ContentHandlercharacters in class org.xml.sax.helpers.DefaultHandlerorg.xml.sax.SAXException
public void ignorableWhitespace(char[] ch,
int start,
int length)
ignorableWhitespace in interface org.xml.sax.ContentHandlerignorableWhitespace in class org.xml.sax.helpers.DefaultHandler
public void endElement(java.lang.String uri,
java.lang.String localName,
java.lang.String name)
throws org.xml.sax.SAXException
endElement in interface org.xml.sax.ContentHandlerendElement in class org.xml.sax.helpers.DefaultHandlerorg.xml.sax.SAXException
public void processingInstruction(java.lang.String target,
java.lang.String data)
throws org.xml.sax.SAXException
processingInstruction in interface org.xml.sax.ContentHandlerprocessingInstruction in class org.xml.sax.helpers.DefaultHandlerorg.xml.sax.SAXException
public void error(org.xml.sax.SAXParseException sax)
throws org.xml.sax.SAXException
error in interface org.xml.sax.ErrorHandlererror in class org.xml.sax.helpers.DefaultHandlerorg.xml.sax.SAXException
public void fatalError(org.xml.sax.SAXParseException sax)
throws org.xml.sax.SAXException
fatalError in interface org.xml.sax.ErrorHandlerfatalError in class org.xml.sax.helpers.DefaultHandlerorg.xml.sax.SAXException
public void warning(org.xml.sax.SAXParseException sax)
throws org.xml.sax.SAXException
warning in interface org.xml.sax.ErrorHandlerwarning in class org.xml.sax.helpers.DefaultHandlerorg.xml.sax.SAXExceptionpublic void setSpacePerLevel(java.lang.String s)
public void setNewLineForCloseTag(java.lang.String s)
public java.lang.String getData()
public static java.lang.String escape(java.lang.String text_pm)
public static void main(java.lang.String[] s)
throws java.lang.Exception
java.lang.Exception
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||