XBRLAPI

A Java API for XBRL


org.xbrlapi.xdt
Class XLinkHandlerImpl

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

public class XLinkHandlerImpl
extends XBRLXLinkHandlerImpl

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
 
Fields inherited from class org.xbrlapi.xlink.handler.XBRLXLinkHandlerImpl
baseURIResolver, elementState, loader
 
Constructor Summary
XLinkHandlerImpl()
          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
 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.
 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)
          Create the resource and add it to the map of arc anchors ready to be processed once the end of the containing extended link has been found.
 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.handler.XBRLXLinkHandlerImpl
equals, hashCode
 
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
 

Constructor Detail

XLinkHandlerImpl

public XLinkHandlerImpl()
XBRL XLink handler constructor

Method Detail

setLoader

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

Overrides:
setLoader in class XBRLXLinkHandlerImpl
Parameters:
loader - The XBRL DTS loader

setBaseURISAXResolver

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

Overrides:
setBaseURISAXResolver in class XBRLXLinkHandlerImpl
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 XBRLXLinkHandlerImpl
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 XBRLXLinkHandlerImpl
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 XBRLXLinkHandlerImpl
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 XBRLXLinkHandlerImpl
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 XBRLXLinkHandlerImpl
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
Create the resource and add it to the map of arc anchors ready to be processed once the end of the containing extended link has been found.

Specified by:
startResource in interface XLinkHandler
Overrides:
startResource in class XBRLXLinkHandlerImpl
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 XBRLXLinkHandlerImpl
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 XBRLXLinkHandlerImpl
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 XBRLXLinkHandlerImpl
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 XBRLXLinkHandlerImpl
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 XBRLXLinkHandlerImpl
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 XBRLXLinkHandlerImpl
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 XBRLXLinkHandlerImpl
Throws:
XLinkException
See Also:
XLinkHandler.endSimpleLink(java.lang.String, java.lang.String, java.lang.String)

setElementState

public void setElementState(ElementState elementState)
Overrides:
setElementState in class XBRLXLinkHandlerImpl
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 XBRLXLinkHandlerImpl
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 XBRLXLinkHandlerImpl
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)

Get Java XBRL API implementation at SourceForge.net.