XBRLAPI

A Java API for XBRL


org.xbrlapi.xlink.handler
Class XBRLXLinkHandlerImpl

java.lang.Object
  extended by org.xbrlapi.xlink.XLinkHandlerDefaultImpl
      extended by org.xbrlapi.xlink.handler.XBRLXLinkHandlerImpl
All Implemented Interfaces:
Serializable, XLinkHandler
Direct Known Subclasses:
XLinkHandlerImpl

public class XBRLXLinkHandlerImpl
extends XLinkHandlerDefaultImpl
implements XLinkHandler, Serializable

XBRL XLink Handler This class provides a real world example of an XLink handler for XBRL.

Author:
Geoffrey Shuetrim (geoff@galexy.net)
See Also:
Serialized Form

Field Summary
protected  BaseURISAXResolver baseURIResolver
          The base URI resolver used by the XLink handler
protected  ElementState elementState
          Data required to track the element scheme XPointer expressions that can be used to identify XBRL fragments.
protected  Loader loader
          The XBRL DTS loader that is using this XLink handler
 
Constructor Summary
XBRLXLinkHandlerImpl()
          XBRL XLink handler constructor
 
Method Summary
 void endArc(String namespaceURI, String sName, String qName)
          Handle the end of the arc.
 void endExtendedLink(String namespaceURI, String sName, String qName)
          Nothing needs to be done at the end of the extended link discovery.
 void endLocator(String namespaceURI, String sName, String qName)
          Handle the end of the locator.
 void endResource(String namespaceURI, String sName, String qName)
          Handle the end of the resource.
 void endSimpleLink(String namespaceURI, String sName, String qName)
          Handle the end of the simple link
 boolean equals(Object obj)
           
 void error(String namespaceURI, String lName, String qName, Attributes attrs, String message)
          Walter Hamscher has identified documents in the XBRL community that violate the constraint that attributes not defined in the XLink specification must not be in the XLink namespace.
 int hashCode()
           
 void setBaseURISAXResolver(BaseURISAXResolver resolver)
          Set the base URI resolver for the XBRL XLink handler.
 void setElementState(ElementState elementState)
           
 void setLoader(Loader loader)
          Set the XBRL DTS loader
 void startArc(String namespaceURI, String lName, String qName, Attributes attrs, String from, String to, String arcrole, String title, String show, String actuate)
          Create the arc fragment first.
 void startExtendedLink(String namespaceURI, String lName, String qName, Attributes attrs, String role, String title)
          The extended link processing algorithm, central to this implementation, operates as follows: Store all locators and resources that are found in the extended link in a map of lists where the map is indexed by XLink label attribute values and each list is made up of the locators and resources that have been found in the extended link that carry the same XLink label.
 void startLocator(String namespaceURI, String lName, String qName, Attributes attrs, String href, String role, String title, String label)
          Create the locator fragment and then add it to the map of arc anchors.
 void startResource(String namespaceURI, String lName, String qName, Attributes attrs, String role, String title, String label)
          Handles the start of processing a local resource.
 void startSimpleLink(String namespaceURI, String lName, String qName, Attributes attrs, String href, String role, String arcrole, String title, String show, String actuate)
          Add the href to the set of XML documents to be explored and create the fragment for the simple link.
 void startTitle(String namespaceURI, String lName, String qName, Attributes attrs)
          Creates and stores an XLink title fragment.
 void warning(String namespaceURI, String lName, String qName, Attributes attrs, String message)
          Log a warning message
 void xmlBaseEnd()
          Handle the change of XML Base scope as you step back up the tree
 void xmlBaseStart(String value)
          Handle the XML Base attribute discovery
 
Methods inherited from class org.xbrlapi.xlink.XLinkHandlerDefaultImpl
endTitle, titleCharacters
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.xbrlapi.xlink.XLinkHandler
endTitle, titleCharacters
 

Field Detail

loader

protected Loader loader
The XBRL DTS loader that is using this XLink handler


baseURIResolver

protected BaseURISAXResolver baseURIResolver
The base URI resolver used by the XLink handler


elementState

protected transient ElementState elementState
Data required to track the element scheme XPointer expressions that can be used to identify XBRL fragments.

Constructor Detail

XBRLXLinkHandlerImpl

public XBRLXLinkHandlerImpl()
XBRL XLink handler constructor

Method Detail

setLoader

public void setLoader(Loader loader)
Set the XBRL DTS loader

Parameters:
loader - The XBRL DTS loader

setBaseURISAXResolver

public void setBaseURISAXResolver(BaseURISAXResolver resolver)
Set the base URI resolver for the XBRL XLink handler.

Parameters:
resolver - the base URI resolver used by the XLink handler.

xmlBaseStart

public void xmlBaseStart(String value)
                  throws XLinkException
Handle the XML Base attribute discovery

Specified by:
xmlBaseStart in interface XLinkHandler
Overrides:
xmlBaseStart in class XLinkHandlerDefaultImpl
Parameters:
value - the Value of the XML Base attribute
Throws:
XLinkException
See Also:
XLinkHandler.xmlBaseStart(java.lang.String)

startTitle

public void startTitle(String namespaceURI,
                       String lName,
                       String qName,
                       Attributes attrs)
                throws XLinkException
Creates and stores an XLink title fragment.

Specified by:
startTitle in interface XLinkHandler
Overrides:
startTitle in class XLinkHandlerDefaultImpl
Throws:
XLinkException
See Also:
XLinkHandler.startTitle(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)

xmlBaseEnd

public void xmlBaseEnd()
                throws XLinkException
Handle the change of XML Base scope as you step back up the tree

Specified by:
xmlBaseEnd in interface XLinkHandler
Overrides:
xmlBaseEnd in class XLinkHandlerDefaultImpl
Throws:
XLinkException
See Also:
XLinkHandler.xmlBaseEnd()

startExtendedLink

public void startExtendedLink(String namespaceURI,
                              String lName,
                              String qName,
                              Attributes attrs,
                              String role,
                              String title)
                       throws XLinkException
The extended link processing algorithm, central to this implementation, operates as follows:

Specified by:
startExtendedLink in interface XLinkHandler
Overrides:
startExtendedLink in class XLinkHandlerDefaultImpl
Throws:
XLinkException
See Also:
XLinkHandler.startExtendedLink(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes, java.lang.String, java.lang.String)

endExtendedLink

public void endExtendedLink(String namespaceURI,
                            String sName,
                            String qName)
                     throws XLinkException
Nothing needs to be done at the end of the extended link discovery.

Specified by:
endExtendedLink in interface XLinkHandler
Overrides:
endExtendedLink in class XLinkHandlerDefaultImpl
Throws:
XLinkException
See Also:
XLinkHandler.endExtendedLink(java.lang.String, java.lang.String, java.lang.String)

startResource

public void startResource(String namespaceURI,
                          String lName,
                          String qName,
                          Attributes attrs,
                          String role,
                          String title,
                          String label)
                   throws XLinkException
Description copied from interface: XLinkHandler
Handles the start of processing a local resource.

Specified by:
startResource in interface XLinkHandler
Overrides:
startResource in class XLinkHandlerDefaultImpl
Throws:
XLinkException
See Also:
XLinkHandler.startResource(String, String, String, Attributes, String, String, String)

endResource

public void endResource(String namespaceURI,
                        String sName,
                        String qName)
                 throws XLinkException
Handle the end of the resource.

Specified by:
endResource in interface XLinkHandler
Overrides:
endResource in class XLinkHandlerDefaultImpl
Throws:
XLinkException
See Also:
XLinkHandler.endResource(java.lang.String, java.lang.String, java.lang.String)

startLocator

public void startLocator(String namespaceURI,
                         String lName,
                         String qName,
                         Attributes attrs,
                         String href,
                         String role,
                         String title,
                         String label)
                  throws XLinkException
Create the locator fragment and then add it to the map of arc anchors. Finally queue up the locator href value in the exploration queue.

Specified by:
startLocator in interface XLinkHandler
Overrides:
startLocator in class XLinkHandlerDefaultImpl
Throws:
XLinkException
See Also:
XLinkHandler.startLocator(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes, java.lang.String, java.lang.String, java.lang.String, java.lang.String)

endLocator

public void endLocator(String namespaceURI,
                       String sName,
                       String qName)
                throws XLinkException
Handle the end of the locator.

Specified by:
endLocator in interface XLinkHandler
Overrides:
endLocator in class XLinkHandlerDefaultImpl
Throws:
XLinkException
See Also:
XLinkHandler.endLocator(java.lang.String, java.lang.String, java.lang.String)

startArc

public void startArc(String namespaceURI,
                     String lName,
                     String qName,
                     Attributes attrs,
                     String from,
                     String to,
                     String arcrole,
                     String title,
                     String show,
                     String actuate)
              throws XLinkException
Create the arc fragment first. Then add the arc to the stack of arcs to be processed.

Specified by:
startArc in interface XLinkHandler
Overrides:
startArc in class XLinkHandlerDefaultImpl
Throws:
XLinkException
See Also:
XLinkHandler.startArc(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)

endArc

public void endArc(String namespaceURI,
                   String sName,
                   String qName)
            throws XLinkException
Handle the end of the arc.

Specified by:
endArc in interface XLinkHandler
Overrides:
endArc in class XLinkHandlerDefaultImpl
Throws:
XLinkException
See Also:
XLinkHandler.endArc(java.lang.String, java.lang.String, java.lang.String)

startSimpleLink

public void startSimpleLink(String namespaceURI,
                            String lName,
                            String qName,
                            Attributes attrs,
                            String href,
                            String role,
                            String arcrole,
                            String title,
                            String show,
                            String actuate)
                     throws XLinkException
Add the href to the set of XML documents to be explored and create the fragment for the simple link. TODO Should simple links generate relationship metadata?

Specified by:
startSimpleLink in interface XLinkHandler
Overrides:
startSimpleLink in class XLinkHandlerDefaultImpl
Throws:
XLinkException
See Also:
XLinkHandler.startSimpleLink(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)

endSimpleLink

public void endSimpleLink(String namespaceURI,
                          String sName,
                          String qName)
                   throws XLinkException
Handle the end of the simple link

Specified by:
endSimpleLink in interface XLinkHandler
Overrides:
endSimpleLink in class XLinkHandlerDefaultImpl
Throws:
XLinkException
See Also:
XLinkHandler.endSimpleLink(java.lang.String, java.lang.String, java.lang.String)

setElementState

public void setElementState(ElementState elementState)
Parameters:
elementState - The state for the current element.

error

public void error(String namespaceURI,
                  String lName,
                  String qName,
                  Attributes attrs,
                  String message)
           throws XLinkException
Walter Hamscher has identified documents in the XBRL community that violate the constraint that attributes not defined in the XLink specification must not be in the XLink namespace. To accommodate this imperfection, we catch that kind of error and make it a warning.

Specified by:
error in interface XLinkHandler
Overrides:
error in class XLinkHandlerDefaultImpl
Parameters:
namespaceURI - Namespace of the element generating the error
lName - local name of the element generating the error
qName - qName of the element generating the error
attrs - attributes of the element generating the error
message - The text of the error message
Throws:
XLinkException - if the handler does not deal with the XLink problem internally
See Also:
XLinkHandler.warning(java.lang.String,java.lang.String, java.lang.String, org.xml.sax.Attributes, java.lang.String)

warning

public void warning(String namespaceURI,
                    String lName,
                    String qName,
                    Attributes attrs,
                    String message)
             throws XLinkException
Log a warning message

Specified by:
warning in interface XLinkHandler
Overrides:
warning in class XLinkHandlerDefaultImpl
Parameters:
namespaceURI - Namespace of the element generating the error
lName - local name of the element generating the error
qName - qName of the element generating the error
attrs - attributes of the element generating the error
message - The text of the warning message
Throws:
XLinkException - if the handler does not deal with the XLink warning internally
See Also:
XLinkHandler.warning(java.lang.String,java.lang.String, java.lang.String, org.xml.sax.Attributes, java.lang.String)

hashCode

public int hashCode()
Overrides:
hashCode in class XLinkHandlerDefaultImpl
See Also:
Object.hashCode()

equals

public boolean equals(Object obj)
Overrides:
equals in class XLinkHandlerDefaultImpl
See Also:
Object.equals(java.lang.Object)

Get Java XBRL API implementation at SourceForge.net.