|
Expresso 5-6 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.jcorporate.expresso.ext.report.XMLPrinter
XMLPrinter is a simple (DOM) parser that outputs XML to a Writer stream.
| Field Summary | |
protected int |
_column
The current indention level. |
protected String |
_indent
The indention prefix string. |
protected char |
_indentChar
The character to use for indenting. |
protected int |
_indentLength
The virtual area occupied by an indention. |
protected String |
_newline
The character sequence for a newline. |
protected boolean |
_omitXmlDecl
Set to keep the <? |
protected Writer |
_out
The writer that will contain the XML written. |
static String |
DEFAULT_INDENT
|
protected static org.apache.log4j.Logger |
log
|
static OutputStreamWriter |
SYSTEM_OUT
|
| Constructor Summary | |
XMLPrinter()
|
|
| Method Summary | |
void |
closeWriter()
Closes the output writer ignoring any errors recieved. |
protected String |
convertNewline(String text)
Convert newlines to what we want. |
protected static void |
copyFile(File in,
File out)
|
void |
error(org.xml.sax.SAXParseException ex)
Issue an error |
void |
fatalError(org.xml.sax.SAXParseException ex)
Fatal error. |
protected String |
getIndent(int col)
Get the normal indentation for a level. |
String |
getRequiredClass()
Retrieve a class that must exist in the classpath for this to work. |
Writer |
getWriter()
Get the output writer. |
static void |
main(String[] args)
|
static String |
nodeToString(org.w3c.dom.Node node)
Return the given node as a string. |
void |
outputDocument(org.w3c.dom.Node node)
Output the document whose root element is the specified node. |
void |
print(String string)
Prints the string to the output. |
void |
print(String string,
String indent)
Prints the string to the output at an indentation. |
void |
println(String string)
Prints the string to the output following it with a newline. |
void |
println(String string,
String indent)
Prints the string to the output at an indentation following it with a newline. |
protected void |
printTree(org.w3c.dom.Node node)
Output the node (and children) at the current indentation level. |
protected void |
printTree(org.w3c.dom.Node node,
int col)
Output the node (and children) at the specified indentation level. |
static int |
run(String[] args)
|
static int |
run(String[] args,
XMLPrinter printer)
|
void |
saveDocument(OutputStream os,
org.w3c.dom.Document document)
Override to actually save a DOM document to the output stream via whatever method you desire |
void |
setFile(File file)
Creates an output writer that will create the file specified and any parent directories needed to do so. |
void |
setFile(String filename)
Creates an output writer that will create the file specified and any parent directories needed to do so. |
void |
setIndent(char indentChar,
int size)
Set the indent semantics. |
void |
setIndentSize(int indentSize)
Set the indentation size to the number of characters specified using the current indent character. |
void |
setOmitXmlDecl(boolean b)
Set whether the xml declaration should be output at the start of a document. |
void |
setWriter(Writer out)
Set the output writer. |
static String |
toXML(String html)
Parse an string and convert it to xml style |
static String |
toXML(String html,
boolean escapeAll)
Parse an string and convert it to xml style |
void |
warning(org.xml.sax.SAXParseException ex)
Issue a warning on parsing errors |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected static org.apache.log4j.Logger log
public static final OutputStreamWriter SYSTEM_OUT
public static final String DEFAULT_INDENT
protected Writer _out
protected String _indent
protected char _indentChar
protected int _indentLength
protected int _column
protected boolean _omitXmlDecl
protected String _newline
| Constructor Detail |
public XMLPrinter()
| Method Detail |
public void saveDocument(OutputStream os,
org.w3c.dom.Document document)
throws ExpressoRuntimeException
saveDocument in interface DOMWriteros - The output stream to save todocument - the DOM document representing the config.
ExpressoRuntimeException - if there's an error saving the file.public String getRequiredClass()
getRequiredClass in interface DOMWriter
public void outputDocument(org.w3c.dom.Node node)
throws IOException
IOExceptionpublic void setWriter(Writer out)
public Writer getWriter()
public void setIndentSize(int indentSize)
public void setIndent(char indentChar,
int size)
indentChar - The character to use for indentions.size - The number of characters to use for each indention level.public void setOmitXmlDecl(boolean b)
public void closeWriter()
public void setFile(File file)
throws IOException
IOException
public void setFile(String filename)
throws IOException
IOExceptionpublic static String nodeToString(org.w3c.dom.Node node)
public static String toXML(String html)
html - The string to be parsed
public static String toXML(String html,
boolean escapeAll)
html - The string to be parsedescapeAll - If false, the semicolon, apostrophe, and quote are left alone (useful for text nodes).
public void print(String string,
String indent)
throws IOException
string - The string to print.indent - The indentation to prefix the string.
IOException
public void println(String string,
String indent)
throws IOException
string - The string to print.indent - The indentation to prefix the string.
IOException
public void print(String string)
throws IOException
string - The string to print.
IOException
public void println(String string)
throws IOException
string - The string to print.
IOExceptionprotected String getIndent(int col)
col - The level of indentation.
protected void printTree(org.w3c.dom.Node node,
int col)
throws IOException
IOException
protected void printTree(org.w3c.dom.Node node)
throws IOException
IOExceptionprotected String convertNewline(String text)
public static int run(String[] args,
XMLPrinter printer)
public static int run(String[] args)
public static void main(String[] args)
protected static void copyFile(File in,
File out)
throws IOException
IOExceptionpublic void warning(org.xml.sax.SAXParseException ex)
warning in interface org.xml.sax.ErrorHandlerex - A Sax Parse Exception eventpublic void error(org.xml.sax.SAXParseException ex)
error in interface org.xml.sax.ErrorHandlerex - A Sax Parse Exception event
public void fatalError(org.xml.sax.SAXParseException ex)
throws org.xml.sax.SAXException
fatalError in interface org.xml.sax.ErrorHandlerex - A Sax Parse Exception event
org.xml.sax.SAXException - after logging the Parsing Exception
|
Expresso 5-6 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||