Expresso 5-6

com.jcorporate.expresso.ext.report
Class DocBookPrinter

java.lang.Object
  extended bycom.jcorporate.expresso.ext.report.XMLPrinter
      extended bycom.jcorporate.expresso.ext.report.DocBookPrinter
All Implemented Interfaces:
DOMWriter, org.xml.sax.ErrorHandler

public class DocBookPrinter
extends XMLPrinter

A (DOM) parser that understands the docbook schema and prints it nicely.

Author:
David Lloyd

Field Summary
protected  Set _inlineTagSet
          Set of inline tags.
protected  int _maxFormatLen
          The maximum character count (including indentions) allowed for single line text.
 
Fields inherited from class com.jcorporate.expresso.ext.report.XMLPrinter
_column, _indent, _indentChar, _indentLength, _newline, _omitXmlDecl, _out, DEFAULT_INDENT, log, SYSTEM_OUT
 
Constructor Summary
DocBookPrinter()
           
 
Method Summary
 void error(org.xml.sax.SAXParseException ex)
          Issue an error
 void fatalError(org.xml.sax.SAXParseException ex)
          Fatal error.
protected  String formatParaText(String text)
          Print the text formatted for a tag that does not place significance on multiple whitespace.
protected  int getIndentLength(int col)
           
protected  String[] getInlineTags()
           
protected  boolean isInlineTag(org.w3c.dom.Node node)
           
protected  boolean isInlineTag(String tagName)
           
protected  boolean isParaTag(org.w3c.dom.Node node)
           
protected  boolean isParaTag(String tagName)
           
protected  boolean isPreTag(org.w3c.dom.Node node)
           
protected  boolean isPreTag(String tagName)
           
static void main(String[] args)
           
static String nodeToString(org.w3c.dom.Node node)
          Return the given node as a string.
static void nodeToString(org.w3c.dom.Node node, Writer writer)
          Print the given node to a writer.
protected  boolean printFormatted(String value)
          Print the text formatted for a tag that does not place significance on multiple whitespace.
protected  void printTree(org.w3c.dom.Node node)
          Override to provide tag relative intelligence.
static int run(String[] args)
           
 void warning(org.xml.sax.SAXParseException ex)
          Issue a warning on parsing errors
 
Methods inherited from class com.jcorporate.expresso.ext.report.XMLPrinter
closeWriter, convertNewline, copyFile, getIndent, getRequiredClass, getWriter, outputDocument, print, print, println, println, printTree, run, saveDocument, setFile, setFile, setIndent, setIndentSize, setOmitXmlDecl, setWriter, toXML, toXML
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_maxFormatLen

protected int _maxFormatLen
The maximum character count (including indentions) allowed for single line text.


_inlineTagSet

protected Set _inlineTagSet
Set of inline tags.

Constructor Detail

DocBookPrinter

public DocBookPrinter()
Method Detail

nodeToString

public static String nodeToString(org.w3c.dom.Node node)
Return the given node as a string. If any error occurs in processing (likely an io exception from outputDocument()), null will be returned.


nodeToString

public static void nodeToString(org.w3c.dom.Node node,
                                Writer writer)
                         throws IOException
Print the given node to a writer.

Throws:
IOException

printTree

protected void printTree(org.w3c.dom.Node node)
                  throws IOException
Override to provide tag relative intelligence.

Overrides:
printTree in class XMLPrinter
Throws:
IOException

isPreTag

protected boolean isPreTag(String tagName)
Returns:
True if the tag name is a docbook pre-formatted tag.

isPreTag

protected boolean isPreTag(org.w3c.dom.Node node)
Returns:
True if the node is a docbook pre-formatted tag.

isParaTag

protected boolean isParaTag(String tagName)
Returns:
True if the tag name is a docbook paragraph tag.

isParaTag

protected boolean isParaTag(org.w3c.dom.Node node)
Returns:
True if the node is a docbook paragraph tag.

isInlineTag

protected boolean isInlineTag(org.w3c.dom.Node node)
Returns:
True if the node is a docbook inline tag.

isInlineTag

protected boolean isInlineTag(String tagName)
Returns:
True if the tag name is a docbook inline tag.

getInlineTags

protected String[] getInlineTags()
Returns:
The list of inline tags.

getIndentLength

protected int getIndentLength(int col)
Returns:
The virtual area occupied by a indentation level.

printFormatted

protected boolean printFormatted(String value)
                          throws IOException
Print the text formatted for a tag that does not place significance on multiple whitespace. This will layout the text nicely for viewing, short text is placed inline while long text is formatted into a block. The threshhold is defined by _maxFormatLen. An example is docbook's <para>.

Parameters:
value - The text to print.
Throws:
IOException

formatParaText

protected String formatParaText(String text)
Print the text formatted for a tag that does not place significance on multiple whitespace. This will layout the text into a block good for viewing. An example is docbook's <para>.

Parameters:
text - The text to print.

run

public static int run(String[] args)

main

public static void main(String[] args)

warning

public void warning(org.xml.sax.SAXParseException ex)
Issue a warning on parsing errors

Specified by:
warning in interface org.xml.sax.ErrorHandler
Overrides:
warning in class XMLPrinter
Parameters:
ex - A Sax Parse Exception event

error

public void error(org.xml.sax.SAXParseException ex)
Issue an error

Specified by:
error in interface org.xml.sax.ErrorHandler
Overrides:
error in class XMLPrinter
Parameters:
ex - A Sax Parse Exception event

fatalError

public void fatalError(org.xml.sax.SAXParseException ex)
                throws org.xml.sax.SAXException
Fatal error. Used Internally for parsing only

Specified by:
fatalError in interface org.xml.sax.ErrorHandler
Overrides:
fatalError in class XMLPrinter
Parameters:
ex - A Sax Parse Exception event
Throws:
org.xml.sax.SAXException - after logging the Parsing Exception

Expresso 5-6

Please see www.jcorporate.com for information about new Expresso releases.