com.lowagie.text.xml
Class SAXiTextHandler

java.lang.Object
  extended byorg.xml.sax.helpers.DefaultHandler
      extended bycom.lowagie.text.xml.SAXiTextHandler
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler
Direct Known Subclasses:
SAXmyHandler

public class SAXiTextHandler
extends org.xml.sax.helpers.DefaultHandler

The Tags-class maps several XHTML-tags to iText-objects.


Field Summary
protected  int chapters
          Counts the number of chapters in this document.
protected  boolean controlOpenClose
          This is a flag that can be set, if you want to open and close the Document-object yourself.
protected  Chunk currentChunk
          This is the current chunk to which characters can be added.
protected  DocListener document
          This is the resulting document.
protected  boolean ignore
          This is the current chunk to which characters can be added.
protected  Stack stack
          This is a Stack of objects, waiting to be added to the document.
 
Constructor Summary
SAXiTextHandler(DocListener document)
          Constructs a new SAXiTextHandler that will translate all the events triggered by the parser to actions on the Document-object.
 
Method Summary
 void characters(char[] ch, int start, int length)
          This method gets called when characters are encountered.
 void endElement(String uri, String lname, String name)
          This method gets called when an end tag is encountered.
 void handleEndingTags(String name)
          This method deals with the starting tags.
 void handleStartingTags(String name, Properties attributes)
          This method deals with the starting tags.
 void ignorableWhitespace(char[] ch, int start, int length)
          This method gets called when ignorable white space encountered.
protected  boolean isDocumentRoot(String tag)
          Checks if a certain tag corresponds with the roottag.
private  boolean isNewline(String tag)
          Checks if a certain tag corresponds with the newpage-tag.
private  boolean isNewpage(String tag)
          Checks if a certain tag corresponds with the newpage-tag.
 void setControlOpenClose(boolean controlOpenClose)
          Sets the parameter that allows you to enable/disable the control over the Document.open() and Document.close() method.
 void startElement(String uri, String lname, String name, org.xml.sax.Attributes attrs)
          This method gets called when a start tag is encountered.
 
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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

document

protected DocListener document
This is the resulting document.


stack

protected Stack stack
This is a Stack of objects, waiting to be added to the document.


chapters

protected int chapters
Counts the number of chapters in this document.


currentChunk

protected Chunk currentChunk
This is the current chunk to which characters can be added.


ignore

protected boolean ignore
This is the current chunk to which characters can be added.


controlOpenClose

protected boolean controlOpenClose
This is a flag that can be set, if you want to open and close the Document-object yourself.

Constructor Detail

SAXiTextHandler

public SAXiTextHandler(DocListener document)
Constructs a new SAXiTextHandler that will translate all the events triggered by the parser to actions on the Document-object.

Parameters:
document - this is the document on which events must be triggered
Method Detail

setControlOpenClose

public void setControlOpenClose(boolean controlOpenClose)
Sets the parameter that allows you to enable/disable the control over the Document.open() and Document.close() method.

If you set this parameter to true (= default), the parser will open the Document object when the start-root-tag is encounterd and close it when the end-root-tag is met. If you set it to false, you have to open and close the Document object yourself.

Parameters:
controlOpenClose - set this to false if you plan to open/close the Document yourself

startElement

public void startElement(String uri,
                         String lname,
                         String name,
                         org.xml.sax.Attributes attrs)
This method gets called when a start tag is encountered.

Parameters:
name - the name of the tag that is encountered
attrs - the list of attributes

handleStartingTags

public void handleStartingTags(String name,
                               Properties attributes)
This method deals with the starting tags.

Parameters:
name - the name of the tag
attributes - the list of attributes

ignorableWhitespace

public void ignorableWhitespace(char[] ch,
                                int start,
                                int length)
This method gets called when ignorable white space encountered.

Parameters:
ch - an array of characters
start - the start position in the array
length - the number of characters to read from the array

characters

public void characters(char[] ch,
                       int start,
                       int length)
This method gets called when characters are encountered.

Parameters:
ch - an array of characters
start - the start position in the array
length - the number of characters to read from the array

endElement

public void endElement(String uri,
                       String lname,
                       String name)
This method gets called when an end tag is encountered.

Parameters:
name - the name of the tag that ends

handleEndingTags

public void handleEndingTags(String name)
This method deals with the starting tags.

Parameters:
name - the name of the tag

isNewpage

private boolean isNewpage(String tag)
Checks if a certain tag corresponds with the newpage-tag.

Parameters:
tag - a presumed tagname
Returns:
true or false

isNewline

private boolean isNewline(String tag)
Checks if a certain tag corresponds with the newpage-tag.

Parameters:
tag - a presumed tagname
Returns:
true or false

isDocumentRoot

protected boolean isDocumentRoot(String tag)
Checks if a certain tag corresponds with the roottag.

Parameters:
tag - a presumed tagname
Returns:
true if tag equals itext, false otherwise.