se.biltmore.tools.odttoapt.maven.plugin
Class OdtSAXHandler

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by se.biltmore.tools.odttoapt.maven.plugin.OdtSAXHandler
All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler

public class OdtSAXHandler
extends DefaultHandler

This handles the relevant SAX events from the SAX parser for extracting information from the odt content.xml file. It builds up a structure of APT models following the structure of the xml document, but producing output of an APT document.

Do getDocument() after parsing is done.


Nested Class Summary
private static class OdtSAXHandler.Current
          This represents what is currently being parsed.
 
Field Summary
private  OdtSAXHandler.Current current
          The currently parsed part.
private  APTDocument document
          The APT document we will be populating.
private  ImageHandler imageHandler
          The image handler to use for extracting images.
private  Stack<OdtSAXHandler.Current> parseStack
          The parse stack.
private  Map<String,String> styleExtensions
          Holds any received style extensions.
 
Constructor Summary
OdtSAXHandler(ImageHandler imageHandler)
          Creates a new OdtSAXHandler instance.
 
Method Summary
 void characters(char[] ch, int start, int length)
          Any text event.
 void endElement(String uri, String localName, String qName)
          The end element event.
private  String getBaseStyle(String style)
          Looks through all style extensions and returns the base style.
 APTDocument getDocument()
          Returns the populated document.
 void startElement(String uri, String localName, String qName, Attributes attributes)
          The start element event.
 
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

document

private APTDocument document
The APT document we will be populating.


parseStack

private Stack<OdtSAXHandler.Current> parseStack
The parse stack.


current

private OdtSAXHandler.Current current
The currently parsed part.


imageHandler

private ImageHandler imageHandler
The image handler to use for extracting images.


styleExtensions

private Map<String,String> styleExtensions
Holds any received style extensions.

Constructor Detail

OdtSAXHandler

public OdtSAXHandler(ImageHandler imageHandler)
Creates a new OdtSAXHandler instance.

Parameters:
imageHandler - The image handler to delegate to for found images.
Method Detail

getDocument

public APTDocument getDocument()
Returns the populated document.


getBaseStyle

private String getBaseStyle(String style)
Looks through all style extensions and returns the base style. If the specified style is not an extension then that specific style will be returned, so it is safe to pass any style through this.

Parameters:
style -

startElement

public void startElement(String uri,
                         String localName,
                         String qName,
                         Attributes attributes)
                  throws SAXException
The start element event.

Specified by:
startElement in interface ContentHandler
Overrides:
startElement in class DefaultHandler
Parameters:
uri - Seems to be blank!
localName - Seems to be blank!
qName - The fully qualified element name.
attributes - The element attributes.
Throws:
SAXException

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws SAXException
Any text event.

Specified by:
characters in interface ContentHandler
Overrides:
characters in class DefaultHandler
Parameters:
ch - An array of text characters.
start - The staring point in the character array.
length - The amount of valid character in the array.
Throws:
SAXException

endElement

public void endElement(String uri,
                       String localName,
                       String qName)
                throws SAXException
The end element event.

Specified by:
endElement in interface ContentHandler
Overrides:
endElement in class DefaultHandler
Parameters:
uri - Seems to be blank!
localName - Seems to be blank!
qName - The fully qualified element name.
Throws:
SAXException


Copyright © 2009-2010 Biltmore Group AB. All Rights Reserved.