public class SAXiTextHandler<T extends XmlPeer> extends DefaultHandler
Modifier and Type | Field and Description |
---|---|
protected int |
chapters
Counts the number of chapters in this document.
|
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 Map<String,T> |
myTags
This hashmap contains all the custom keys and peers.
|
protected Stack<Element> |
stack
This is a
Stack of objects, waiting to be added to the
document. |
Constructor and Description |
---|
SAXiTextHandler(DocListener document) |
SAXiTextHandler(DocListener document,
Map<String,T> myTags) |
SAXiTextHandler(DocListener document,
Map<String,T> myTags,
BaseFont bf) |
Modifier and Type | Method and Description |
---|---|
protected void |
addImage(Image img) |
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.
|
void |
setBaseFont(BaseFont bf)
Sets the font that has to be used.
|
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 localName,
String name,
Attributes attributes)
This method gets called when a start tag is encountered.
|
endDocument, endPrefixMapping, error, fatalError, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
protected DocListener document
protected Stack<Element> stack
Stack
of objects, waiting to be added to the
document.protected int chapters
protected Chunk currentChunk
protected boolean ignore
public SAXiTextHandler(DocListener document)
document
- public SAXiTextHandler(DocListener document, Map<String,T> myTags, BaseFont bf)
document
- myTags
- bf
- public SAXiTextHandler(DocListener document, Map<String,T> myTags)
document
- myTags
- 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 encountered 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(String uri, String localName, String name, @Nullable Attributes attributes)
startElement
in interface ContentHandler
startElement
in class DefaultHandler
uri
- the Uniform Resource IdentifierlocalName
- the local name (without prefix), or the empty string if
Namespace processing is not being performed.name
- the name of the tag that is encounteredattributes
- the list of attributespublic void handleStartingTags(String name, Properties attributes)
name
- the name of the tagattributes
- the list of attributespublic void ignorableWhitespace(char[] ch, int start, int length)
ignorableWhitespace
in interface ContentHandler
ignorableWhitespace
in class 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 ContentHandler
characters
in class 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)
bf
- public void endElement(String uri, String lname, String name)
endElement
in interface ContentHandler
endElement
in class 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(String name)
name
- the name of the tagprotected void addImage(Image img) throws EmptyStackException
EmptyStackException
protected boolean isDocumentRoot(String tag)
tag
- a presumed tagnametrue
if tag equals itext
,false
otherwise.Copyright © 2020. All rights reserved.