public class Parser
extends org.xml.sax.helpers.DefaultHandler
| Modifier and Type | Field and Description |
|---|---|
protected int[] |
counterParents |
protected int[] |
counters |
protected Chunk |
currentChunk |
protected Document |
document |
protected java.util.Stack |
filestack |
protected MarkupParser |
markup |
protected java.util.Stack |
objectstack |
protected java.util.Stack |
outline |
protected int |
previoustitle |
protected java.lang.String[] |
structures |
protected java.util.Stack |
tagstack |
protected java.lang.String |
title |
protected java.lang.String[] |
titles |
protected PdfWriter |
writer |
| Constructor and Description |
|---|
Parser(java.lang.String srcfile)
Constructs a recursive parser object.
|
Parser(java.lang.String srcfile,
java.lang.String title,
java.lang.String[] structures,
java.lang.String[] titles,
int[] counterParents)
Constructs a recursive parser object.
|
| Modifier and Type | Method and Description |
|---|---|
private void |
addObject(Paragraph paragraph)
Creates a new Object and puts it on top of the objectstack.
|
private void |
addObject(Phrase phrase)
Creates a new Object and puts it on top of the objectstack.
|
private void |
addObject(SimpleCell cell)
Creates a new Object and puts it on top of the objectstack.
|
private void |
addObject(SimpleTable table)
Creates a new Object and puts it on top of the objectstack.
|
private void |
addToCurrentChunk(java.lang.String s)
extending the CurrentChunk.
|
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 localName,
java.lang.String qName) |
private void |
flushCurrentChunk()
flushing the CurrentChunk.
|
private boolean |
flushObject()
Deals with the object on top of the objectstack.
|
private void |
parse()
Gets the file on top of the filestack,
parses it
and removes it from the stack.
|
void |
processingInstruction(java.lang.String instruction,
java.lang.String parameter) |
void |
startElement(java.lang.String uri,
java.lang.String localName,
java.lang.String qName,
org.xml.sax.Attributes attributes) |
protected java.util.Stack filestack
protected java.util.Stack outline
protected java.util.Stack tagstack
protected java.util.Stack objectstack
protected Chunk currentChunk
protected Document document
protected PdfWriter writer
protected java.lang.String title
protected java.lang.String[] structures
protected java.lang.String[] titles
protected int[] counterParents
protected int[] counters
protected int previoustitle
protected MarkupParser markup
public Parser(java.lang.String srcfile)
srcfile - the file that has to be parsed.public Parser(java.lang.String srcfile,
java.lang.String title,
java.lang.String[] structures,
java.lang.String[] titles,
int[] counterParents)
srcfile - the file that has to be parsedtitle - the value of the id selector marking a titlestructures - an array with the values of the class selectors marking titles in the complete structuretitles - the strings that have to be added to the titlenumbercounterParents - an array with references from each child in the structure to its parentpublic void startElement(java.lang.String uri,
java.lang.String localName,
java.lang.String qName,
org.xml.sax.Attributes attributes)
throws org.xml.sax.SAXException
startElement in interface org.xml.sax.ContentHandlerstartElement in class org.xml.sax.helpers.DefaultHandlerorg.xml.sax.SAXExceptionContentHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)public void characters(char[] ch,
int start,
int length)
characters in interface org.xml.sax.ContentHandlercharacters in class org.xml.sax.helpers.DefaultHandlerch - an array of charactersstart - the start position in the arraylength - the number of characters to read from the arraypublic void endElement(java.lang.String uri,
java.lang.String localName,
java.lang.String qName)
throws org.xml.sax.SAXException
endElement in interface org.xml.sax.ContentHandlerendElement in class org.xml.sax.helpers.DefaultHandlerorg.xml.sax.SAXExceptionContentHandler.endElement(java.lang.String, java.lang.String, java.lang.String)public void processingInstruction(java.lang.String instruction,
java.lang.String parameter)
throws org.xml.sax.SAXException
processingInstruction in interface org.xml.sax.ContentHandlerprocessingInstruction in class org.xml.sax.helpers.DefaultHandlerorg.xml.sax.SAXExceptionContentHandler.processingInstruction(java.lang.String, java.lang.String)private void flushCurrentChunk()
private void addToCurrentChunk(java.lang.String s)
s - private void addObject(Phrase phrase)
phrase - private void addObject(SimpleTable table)
table - private void addObject(SimpleCell cell)
cell - private void addObject(Paragraph paragraph)
paragraph - private boolean flushObject()
private void parse()
throws javax.xml.parsers.ParserConfigurationException,
java.io.IOException,
org.xml.sax.SAXException
javax.xml.parsers.ParserConfigurationExceptionjava.io.IOExceptionorg.xml.sax.SAXException