XBRLAPI

A Java API for XBRL


org.xbrlapi.sax
Class ContentHandlerImpl

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by org.xbrlapi.sax.BaseContentHandlerImpl
          extended by org.xbrlapi.sax.ContentHandlerImpl
All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler
Direct Known Subclasses:
ContentHandlerImpl

public class ContentHandlerImpl
extends BaseContentHandlerImpl
implements ContentHandler

SAX content handler used to parse a document into an XBRL API data store. The content handler is responsible for identifying XML fragments to be loaded into the data store, as they are parsed and then passing them over to the data loader for creation and storage. The content handler needs to be supplied with a variety of helpers to assist with data storage and XLink processing. These are supplied by the loader.

Author:
Geoffrey Shuetrim (geoff@galexy.net)

Field Summary
protected  List<Identifier> identifiers
          The list of fragment identifiers
 
Fields inherited from class org.xbrlapi.sax.BaseContentHandlerImpl
logger
 
Constructor Summary
ContentHandlerImpl(Loader loader, URI uri)
          Creates the content handler, starting out by identifying the DTS structure that the content handler is discovering.
ContentHandlerImpl(Loader loader, URI uri, String xml)
          Creates the content handler, starting out by identifying the data structure that the content handler is discovering.
 
Method Summary
protected  void addIdentifier(Identifier identifier)
           
protected  void addIdentifier(int index, Identifier identifier)
           
 void characters(char[] buf, int offset, int len)
          Copy characters (trimming white space as required) to the DTSImpl.
 void endElement(String namespaceURI, String lName, String qName)
          The end of an element triggers processing of an extended link if we have reached the end of an extended link.
protected  BaseURISAXResolver getBaseURISAXResolver()
           
 void ignorableWhitespace(char[] buf, int offset, int len)
          Ignore ignorable whitespace
 void processingInstruction(String target, String data)
          Copy across processing instructions to the DTSImpl
protected  void removeIdentifier(int index)
           
 void setDocumentLocator(Locator locator)
          The locator for a document is stored to facilitate resolution of CacheURIImpl's relative to that location.
 void startDocument()
          On starting to parse a document the Base URI resolver is set up with the documents absolute URI.
 void startElement(String namespaceURI, String lName, String qName, Attributes attrs)
          Sets the element state.
 
Methods inherited from class org.xbrlapi.sax.BaseContentHandlerImpl
error, fatalError, getElementState, getIdentifiers, getLoader, getURI, setElementState, setLoader, setURI, warning
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, notationDecl, resolveEntity, skippedEntity, startPrefixMapping, unparsedEntityDecl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.xbrlapi.sax.ContentHandler
error, fatalError, getElementState, getIdentifiers, getLoader, getURI, setElementState, setLoader, setURI, warning
 
Methods inherited from interface org.xml.sax.ContentHandler
endDocument, endPrefixMapping, skippedEntity, startPrefixMapping
 

Field Detail

identifiers

protected List<Identifier> identifiers
The list of fragment identifiers

Constructor Detail

ContentHandlerImpl

public ContentHandlerImpl(Loader loader,
                          URI uri)
                   throws XBRLException
Creates the content handler, starting out by identifying the DTS structure that the content handler is discovering.

Parameters:
loader - The DTS loader that is using this content handler.
uri - The URI of the document being parsed.
Throws:
XBRLException - if any of the parameters are null.

ContentHandlerImpl

public ContentHandlerImpl(Loader loader,
                          URI uri,
                          String xml)
                   throws XBRLException
Creates the content handler, starting out by identifying the data structure that the content handler is discovering.

Parameters:
loader - The data loader that is using this content handler.
uri - The URI of the document being parsed.
xml - The string representation of the XML document being parsed.
Throws:
XBRLException - if any of the parameters are null.
Method Detail

startDocument

public void startDocument()
                   throws SAXException
On starting to parse a document the Base URI resolver is set up with the documents absolute URI. The fragment identifiers are also instantiated and initialised.

Specified by:
startDocument in interface ContentHandler
Overrides:
startDocument in class DefaultHandler
Throws:
SAXException

startElement

public void startElement(String namespaceURI,
                         String lName,
                         String qName,
                         Attributes attrs)
                  throws SAXException
Sets the element state. Increment the fragment children via the loader ???? Stash xsi:schemaLocation attribute URIs for discovery if required. Identifies any new fragment. Adds the fragment, if one is found, to the stack of fragments being built by the loader. Update the map of defined namespaces. Add the element to the current fragment.

Specified by:
startElement in interface ContentHandler
Overrides:
startElement in class DefaultHandler
Throws:
SAXException
See Also:
ContentHandler.startElement(String, String, String, Attributes)

endElement

public void endElement(String namespaceURI,
                       String lName,
                       String qName)
                throws SAXException
The end of an element triggers processing of an extended link if we have reached the end of an extended link. Otherwise, we step up to the parent element unless the element that is ending did not ever become the current element.

Specified by:
endElement in interface ContentHandler
Overrides:
endElement in class DefaultHandler
Throws:
SAXException

ignorableWhitespace

public void ignorableWhitespace(char[] buf,
                                int offset,
                                int len)
                         throws SAXException
Ignore ignorable whitespace

Specified by:
ignorableWhitespace in interface ContentHandler
Overrides:
ignorableWhitespace in class DefaultHandler
Throws:
SAXException

processingInstruction

public void processingInstruction(String target,
                                  String data)
                           throws SAXException
Copy across processing instructions to the DTSImpl

Specified by:
processingInstruction in interface ContentHandler
Overrides:
processingInstruction in class DefaultHandler
Throws:
SAXException

characters

public void characters(char[] buf,
                       int offset,
                       int len)
                throws SAXException
Copy characters (trimming white space as required) to the DTSImpl.

Specified by:
characters in interface ContentHandler
Overrides:
characters in class DefaultHandler
Throws:
SAXException

setDocumentLocator

public void setDocumentLocator(Locator locator)
The locator for a document is stored to facilitate resolution of CacheURIImpl's relative to that location.

Specified by:
setDocumentLocator in interface ContentHandler
Overrides:
setDocumentLocator in class DefaultHandler

getBaseURISAXResolver

protected BaseURISAXResolver getBaseURISAXResolver()
Returns:
the base URI resolver for SAX parsing.

addIdentifier

protected void addIdentifier(Identifier identifier)
Parameters:
identifier - The identifier to add to the list of fragment identifiers used by the content handler.

addIdentifier

protected void addIdentifier(int index,
                             Identifier identifier)
Parameters:
index - The index of the position at which the new identifier is to be inserted in the list of fragment identifiers.
identifier - The identifier to add to the list of fragment identifiers used by the content handler.

removeIdentifier

protected void removeIdentifier(int index)
                         throws XBRLException
Parameters:
index - The index of the identifier to remove from the list of fragment identifiers used by the content handler.
Throws:
XBRLException

Get Java XBRL API implementation at SourceForge.net.