## com.lowagie.text.markup
Class Parser

    java.lang.Object
      org.xml.sax.helpers.DefaultHandler
          com.lowagie.text.markup.Parser

All Implemented Interfaces:
  org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

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

This class allows you to parse files in a tree.

Field Summary
`protected int[]` `counterParents`
`protected int[]` `counters`
`protected Chunk` `currentChunk`
`protected Document` `document`
`protected Stack` `filestack`
`protected MarkupParser` `markup`
`protected Stack` `objectstack`
`protected Stack` `outline`
`protected int` `previoustitle`
`protected String[]` `structures`
`protected Stack` `tagstack`
`protected String` `title`
`protected String[]` `titles`
`protected PdfWriter` `writer`

Constructor Summary
`Parser(String srcfile)` Constructs a recursive parser object.
`Parser(String srcfile, String title, String[] structures, String[] titles, int[] counterParents)` Constructs a recursive parser object.

Method Summary
`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(String s)` extending the CurrentChunk.
`void` `characters(char[] ch, int start, int length)` This method gets called when characters are encountered.
`void` `endElement(String uri, String localName, 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(String instruction, String parameter)`
`void` `startElement(String uri, String localName, String qName, org.xml.sax.Attributes attributes)`

Methods inherited from class org.xml.sax.helpers.DefaultHandler
`endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, 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

### filestack

    protected Stack filestack

### outline

    protected Stack outline

### tagstack

    protected Stack tagstack

### objectstack

    protected Stack objectstack

### currentChunk

    protected Chunk currentChunk

### document

    protected Document document

### writer

    protected PdfWriter writer

### title

    protected String title

### structures

    protected String[] structures

### titles

    protected String[] titles

### counterParents

    protected int[] counterParents

### counters

    protected int[] counters

### previoustitle

    protected int previoustitle

### markup

    protected MarkupParser markup

Constructor Detail

### Parser

    public Parser(String srcfile)

  Constructs a recursive parser object.

Parameters:
  `srcfile` - the file that has to be parsed.

### Parser

    public Parser(String srcfile,
                  String title,
                  String[] structures,
                  String[] titles,
                  int[] counterParents)

  Constructs a recursive parser object.

Parameters:
  `srcfile` - the file that has to be parsed
  `title` - the value of the id selector marking a title
  `structures` - an array with the values of the class selectors marking titles in the complete structure
  `titles` - the strings that have to be added to the titlenumber
  `counterParents` - an array with references from each child in the structure to its parent

Method Detail

### startElement

    public void startElement(String uri,
                             String localName,
                             String qName,
                             org.xml.sax.Attributes attributes)
                      throws org.xml.sax.SAXException

  Throws:
    `org.xml.sax.SAXException`
  See Also:
    `ContentHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)`

### 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 localName,
                           String qName)
                    throws org.xml.sax.SAXException

  Throws:
    `org.xml.sax.SAXException`
  See Also:
    `ContentHandler.endElement(java.lang.String, java.lang.String, java.lang.String)`

### processingInstruction

    public void processingInstruction(String instruction,
                                      String parameter)
                               throws org.xml.sax.SAXException

  Throws:
    `org.xml.sax.SAXException`
  See Also:
    `ContentHandler.processingInstruction(java.lang.String, java.lang.String)`

### flushCurrentChunk

    private void flushCurrentChunk()

  flushing the CurrentChunk.

### addToCurrentChunk

    private void addToCurrentChunk(String s)

  extending the CurrentChunk.

  Parameters:
    `s` -

### addObject

    private void addObject(Phrase phrase)

  Creates a new Object and puts it on top of the objectstack.

  Parameters:
    `phrase` -

### addObject

    private void addObject(SimpleTable table)

  Creates a new Object and puts it on top of the objectstack.

  Parameters:
    `table` -

### addObject

    private void addObject(SimpleCell cell)

  Creates a new Object and puts it on top of the objectstack.

  Parameters:
    `cell` -

### addObject

    private void addObject(Paragraph paragraph)

  Creates a new Object and puts it on top of the objectstack.

  Parameters:
    `paragraph` -

### flushObject

    private boolean flushObject()

  Deals with the object on top of the objectstack.

  Returns:
    false if there was no valid object on the objectstack.

### parse

    private void parse()
                throws javax.xml.parsers.ParserConfigurationException,
                       IOException,
                       org.xml.sax.SAXException

  Gets the file on top of the filestack, parses it and removes it from the stack.

  Throws:
    `javax.xml.parsers.ParserConfigurationException`
    `IOException`
    `org.xml.sax.SAXException`