public class SAXiTextHandler
extends org.xml.sax.helpers.DefaultHandler
Modifier and Type | Field and Description |
---|---|
private BaseFont |
bf |
(package private) float |
bottomMargin
current margin of a page.
|
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.
|
(package private) float |
leftMargin
current margin of a page.
|
protected java.util.HashMap |
myTags |
(package private) float |
rightMargin
current margin of a page.
|
protected java.util.Stack |
stack
This is a
Stack of objects, waiting to be added to the
document. |
(package private) float |
topMargin
current margin of a page.
|
Constructor and Description |
---|
SAXiTextHandler(DocListener document) |
SAXiTextHandler(DocListener document,
java.util.HashMap myTags) |
SAXiTextHandler(DocListener document,
HtmlTagMap myTags) |
SAXiTextHandler(DocListener document,
HtmlTagMap myTags,
BaseFont bf) |
Modifier and Type | Method and Description |
---|---|
void |
characters(char[] ch,
int start,
int length)
This method gets called when characters are encountered.
|
void |
endElement(java.lang.String uri,
java.lang.String lname,
java.lang.String name)
This method gets called when an end tag is encountered.
|
void |
handleEndingTags(java.lang.String name)
This method deals with the starting tags.
|
void |
handleStartingTags(java.lang.String name,
java.util.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(java.lang.String tag)
Checks if a certain tag corresponds with the roottag.
|
private boolean |
isNewline(java.lang.String tag)
Checks if a certain tag corresponds with the newpage-tag.
|
private boolean |
isNewpage(java.lang.String tag)
Checks if a certain tag corresponds with the newpage-tag.
|
void |
setBaseFont(BaseFont bf) |
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(java.lang.String uri,
java.lang.String lname,
java.lang.String name,
org.xml.sax.Attributes attrs)
This method gets called when a start tag is encountered.
|
protected DocListener document
protected java.util.Stack stack
Stack
of objects, waiting to be added to the
document.protected int chapters
protected Chunk currentChunk
protected boolean ignore
protected boolean controlOpenClose
float topMargin
float rightMargin
float leftMargin
float bottomMargin
protected java.util.HashMap myTags
private BaseFont bf
public SAXiTextHandler(DocListener document) throws java.io.IOException
document
- bf
- DocumentException
java.io.IOException
public SAXiTextHandler(DocListener document, HtmlTagMap myTags) throws java.io.IOException
document
- myTags
- DocumentException
java.io.IOException
public SAXiTextHandler(DocListener document, HtmlTagMap myTags, BaseFont bf) throws java.io.IOException
document
- myTags
- bf
- DocumentException
java.io.IOException
public SAXiTextHandler(DocListener document, java.util.HashMap myTags) throws java.io.IOException
document
- myTags
- DocumentException
java.io.IOException
public void setControlOpenClose(boolean controlOpenClose)
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.
controlOpenClose
- set this to false if you plan to open/close the Document
yourselfpublic void startElement(java.lang.String uri, java.lang.String lname, java.lang.String name, org.xml.sax.Attributes attrs)
startElement
in interface org.xml.sax.ContentHandler
startElement
in class org.xml.sax.helpers.DefaultHandler
uri
- the Uniform Resource Identifierlname
- the local name (without prefix), or the empty string if
Namespace processing is not being performed.name
- the name of the tag that is encounteredattrs
- the list of attributespublic void handleStartingTags(java.lang.String name, java.util.Properties attributes)
name
- the name of the tagattributes
- the list of attributespublic void ignorableWhitespace(char[] ch, int start, int length)
ignorableWhitespace
in interface org.xml.sax.ContentHandler
ignorableWhitespace
in class org.xml.sax.helpers.DefaultHandler
ch
- an array of charactersstart
- the start position in the arraylength
- the number of characters to read from the arraypublic void characters(char[] ch, int start, int length)
characters
in interface org.xml.sax.ContentHandler
characters
in class org.xml.sax.helpers.DefaultHandler
ch
- an array of charactersstart
- the start position in the arraylength
- the number of characters to read from the arraypublic void setBaseFont(BaseFont bf)
public void endElement(java.lang.String uri, java.lang.String lname, java.lang.String name)
endElement
in interface org.xml.sax.ContentHandler
endElement
in class org.xml.sax.helpers.DefaultHandler
uri
- the Uniform Resource Identifierlname
- the local name (without prefix), or the empty string if
Namespace processing is not being performed.name
- the name of the tag that endspublic void handleEndingTags(java.lang.String name)
name
- the name of the tagprivate boolean isNewpage(java.lang.String tag)
tag
- a presumed tagnametrue
or false
private boolean isNewline(java.lang.String tag)
tag
- a presumed tagnametrue
or false
protected boolean isDocumentRoot(java.lang.String tag)
tag
- a presumed tagnametrue
if tag equals itext
,false
otherwise.