org.crosswire.jsword.book.filter.thml

## Class CustomHandler

- java.lang.Object
- - org.xml.sax.helpers.DefaultHandler
  - - org.crosswire.jsword.book.filter.thml.CustomHandler

- All Implemented Interfaces:
    ContentHandler, DTDHandler, EntityResolver, ErrorHandler

      public class CustomHandler
      extends DefaultHandler

  To convert SAX events into OSIS events.

  This is based upon the THML reference page: http://www.ccel.org/ThML/ThML1.04.htm to work out what the tags meant.

  Author:
    Joe Walker
  See Also:
    `The GNU Lesser General Public License for details.`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private Book` | `book` The book being parsed.
    `private Key` | `key` The book being parsed.
    `private org.jdom2.Element` | `rootElement` When the document is parsed, this is the last element popped off the stack.
    `private LinkedList<org.jdom2.Content>` | `stack` The stack of elements that we have created
    `private static Map<String,Tag>` | `TAG_MAP` The known tag types

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CustomHandler(Book book, Key key)` Simple ctor

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `characters(char[] data, int offset, int length)`
    `void` | `endElement(String uri, String localname, String qname)`
    `org.jdom2.Element` | `getRootElement()`
    `private Tag` | `getTag(String localname, String qname)`
    `void` | `startElement(String uri, String localname, String qname, Attributes attrs)`

    - ### Methods inherited from class org.xml.sax.helpers.DefaultHandler

      `endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, 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

    - #### rootElement

          private org.jdom2.Element rootElement

      When the document is parsed, this is the last element popped off the stack.

    - #### book

          private Book book

      The book being parsed.

    - #### key

          private Key key

      The book being parsed.

    - #### stack

          private LinkedList<org.jdom2.Content> stack

      The stack of elements that we have created

    - #### TAG_MAP

          private static final Map<String,Tag> TAG_MAP

      The known tag types

  - ### Constructor Detail

    - #### CustomHandler

          public CustomHandler(Book book,
                       Key key)

      Simple ctor
      Parameters:
        `book` - the book
        `key` - the key

  - ### Method Detail

    - #### startElement

          public void startElement(String uri,
                          String localname,
                          String qname,
                          Attributes attrs)
                            throws SAXException

      Specified by:
        `startElement` in interface `ContentHandler`
      Overrides:
        `startElement` in class `DefaultHandler`
      Throws:
        `SAXException`

    - #### characters

          public void characters(char[] data,
                        int offset,
                        int length)

      Specified by:
        `characters` in interface `ContentHandler`
      Overrides:
        `characters` in class `DefaultHandler`

    - #### endElement

          public void endElement(String uri,
                        String localname,
                        String qname)

      Specified by:
        `endElement` in interface `ContentHandler`
      Overrides:
        `endElement` in class `DefaultHandler`

    - #### getRootElement

          public org.jdom2.Element getRootElement()

      Returns:
        the root element

    - #### getTag

          private Tag getTag(String localname,
                   String qname)