XBRLAPI

A Java API for XBRL


org.xbrlapi.builder
Class BuilderImpl

java.lang.Object
  extended by org.xbrlapi.builder.BuilderImpl
All Implemented Interfaces:
Builder

public class BuilderImpl
extends Object
implements Builder

Class defining the SAX event handlers that enable a fragment to be built up during DTS discovery. This should only be instantiated during the creation of a fragment subclass. The builder is responsible for construction of the XML constituting the fragment itself and the XML that contains the metadata about the fragment and its relationship to other fragments.

Author:
Geoffrey Shuetrim (geoff@galexy.net)

Constructor Summary
BuilderImpl()
          Create the builder making sure that the static DOM is instantiated and creating the metadata root element.
BuilderImpl(Document dom)
          Create the builder controlling which XML DOM is being used.
 
Method Summary
 void appendAttributeDecl(String eName, String aName, String type, String valueDefault, String value)
          Append an attribute DTD declaration
 void appendComment(String text)
          Append a comment node.
 void appendElement(URI namespaceURI, String lName, String qName)
          Insert a new element without attributes.
 void appendElement(URI namespaceURI, String lName, String qName, Attributes attrs)
          Append an element node.
 void appendElementDecl(String name, String model)
          Append an element DTD declaration.
 void appendExternalEntityDecl(String name, String publicId, String systemId)
          Append an external entity DTD declarations.
 void appendInternalEntityDecl(String name, String value)
          Append an internal entity DTD declaration.
 void appendMetadataElement(String eName, Map<String,String> attributes)
          Appends a child element to the root metadata element.
 void appendNotationDecl(String name, String publicId, String systemId)
          Append a notation declaration.
 void appendProcessingInstruction(String target, String data)
          Append a processing instruction node
 void appendText(String text)
          Append a text node.
 void appendUnparsedEntityDecl(String name, String publicId, String systemId, String notationName)
          Append an unparsed entity declaration.
 void close()
          Restores the builder to its pre-use state.
 void endElement(String namespaceURI, String lName, String qName)
          Update the insertion point for new content when reaching the end of an element.
 Element getData()
          Get the Document object used to build the fragment.
 Element getInsertionPoint()
          Get the insertion point for new data content.
 String getMetaAttribute(String name)
          Get a metadata attribute.
 Element getMetadata()
          Get the metadata DOM document.
 boolean hasMetaAttribute(String name)
           
 boolean isNewFragment()
          Returns true iff the builder has not yet added an element to the fragment.
 void removeMetaAttribute(String name)
          Remove a metadata attribute.
 void removeMetadataElement(String eName, HashMap<String,String> attributes)
          Removes a child element from the metadata root element by specifying the name of the child and the value of the element's text content and/or the value of a named attribute.
 void setMetaAttribute(String name, String value)
          Set a metadata attribute.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BuilderImpl

public BuilderImpl(Document dom)
            throws XBRLException
Create the builder controlling which XML DOM is being used.

Parameters:
dom - The DOM to use in the builder.
Throws:
XBRLException - if the DOM is null.

BuilderImpl

public BuilderImpl()
            throws XBRLException
Create the builder making sure that the static DOM is instantiated and creating the metadata root element.

Throws:
XBRLException - if the DOM Builder cannot be instantiated.
Method Detail

close

public void close()
Restores the builder to its pre-use state.


getData

public Element getData()
                throws XBRLException
Description copied from interface: Builder
Get the Document object used to build the fragment.

Specified by:
getData in interface Builder
Returns:
the data XML structure.
Throws:
XBRLException - if the data has not been built yet.
See Also:
Builder.getData()

getMetadata

public Element getMetadata()
Get the metadata DOM document.

Specified by:
getMetadata in interface Builder
Returns:
the metadata XML structure.

isNewFragment

public boolean isNewFragment()
Description copied from interface: Builder
Returns true iff the builder has not yet added an element to the fragment.

Specified by:
isNewFragment in interface Builder
Returns:
true iff the builder has not yet added an element to the fragment.

getInsertionPoint

public Element getInsertionPoint()
Get the insertion point for new data content.

Specified by:
getInsertionPoint in interface Builder
Returns:
the insertion point for new data nodes.

appendText

public void appendText(String text)
                throws XBRLException
Append a text node.

Specified by:
appendText in interface Builder
Parameters:
text - The node to be appended.
Throws:
XBRLException - if the node cannot be appended.

appendProcessingInstruction

public void appendProcessingInstruction(String target,
                                        String data)
                                 throws XBRLException
Append a processing instruction node

Specified by:
appendProcessingInstruction in interface Builder
Parameters:
target - The processing target application identifier.
data - The data defining what is to be done.
Throws:
XBRLException - if the node cannot be appended.

appendComment

public void appendComment(String text)
                   throws XBRLException
Append a comment node.

Specified by:
appendComment in interface Builder
Parameters:
text - The data constituting the content of the comment.
Throws:
XBRLException - if the node cannot be appended.

appendElement

public void appendElement(URI namespaceURI,
                          String lName,
                          String qName,
                          Attributes attrs)
                   throws XBRLException
Append an element node.

Specified by:
appendElement in interface Builder
Parameters:
namespaceURI - The namespace of the element found by the SAX parser.
lName - The local name of the element found by the SAX parser.
qName - The QName of the element found by the SAX parser.
attrs - The set of attributes found by the SAX parser.
Throws:
XBRLException - if the node cannot be appended.

appendElement

public void appendElement(URI namespaceURI,
                          String lName,
                          String qName)
                   throws XBRLException
Insert a new element without attributes.

Specified by:
appendElement in interface Builder
Parameters:
namespaceURI - The namespace of the element found by the SAX parser.
lName - The local name of the element found by the SAX parser.
qName - The QName of the element found by the SAX parser.
Throws:
XBRLException - if the node cannot be appended.

endElement

public void endElement(String namespaceURI,
                       String lName,
                       String qName)
                throws XBRLException
Description copied from interface: Builder
Update the insertion point for new content when reaching the end of an element.

Specified by:
endElement in interface Builder
Parameters:
namespaceURI - The namespace URI of the element that is ending.
lName - The local name of the element that is ending.
qName - The QName of the element that is ending.
Throws:
XBRLException - if the current insertion point is not an element node or if the new (parent) insertion point is not an element node.
See Also:
Builder.endElement(String, String, String)

appendNotationDecl

public void appendNotationDecl(String name,
                               String publicId,
                               String systemId)
                        throws XBRLException
Append a notation declaration.

Specified by:
appendNotationDecl in interface Builder
Throws:
XBRLException

appendUnparsedEntityDecl

public void appendUnparsedEntityDecl(String name,
                                     String publicId,
                                     String systemId,
                                     String notationName)
                              throws XBRLException
Append an unparsed entity declaration.

Specified by:
appendUnparsedEntityDecl in interface Builder
Throws:
XBRLException

appendElementDecl

public void appendElementDecl(String name,
                              String model)
                       throws XBRLException
Append an element DTD declaration.

Specified by:
appendElementDecl in interface Builder
Throws:
XBRLException

appendInternalEntityDecl

public void appendInternalEntityDecl(String name,
                                     String value)
                              throws XBRLException
Append an internal entity DTD declaration.

Specified by:
appendInternalEntityDecl in interface Builder
Throws:
XBRLException

appendExternalEntityDecl

public void appendExternalEntityDecl(String name,
                                     String publicId,
                                     String systemId)
                              throws XBRLException
Append an external entity DTD declarations.

Specified by:
appendExternalEntityDecl in interface Builder
Throws:
XBRLException

appendAttributeDecl

public void appendAttributeDecl(String eName,
                                String aName,
                                String type,
                                String valueDefault,
                                String value)
                         throws XBRLException
Append an attribute DTD declaration

Specified by:
appendAttributeDecl in interface Builder
Throws:
XBRLException

setMetaAttribute

public void setMetaAttribute(String name,
                             String value)
Set a metadata attribute.

Specified by:
setMetaAttribute in interface Builder
Parameters:
name - The name of the attribute.
value - The value of the attribute.

getMetaAttribute

public String getMetaAttribute(String name)
Description copied from interface: Builder
Get a metadata attribute.

Specified by:
getMetaAttribute in interface Builder
Parameters:
name - The name of the attribute.
Returns:
the string value of the metadata attribute or null if the XML does not have the specified attribute.
See Also:
Builder.getMetaAttribute(String)

hasMetaAttribute

public boolean hasMetaAttribute(String name)
Specified by:
hasMetaAttribute in interface Builder
Parameters:
name - The name of the attribute.
Returns:
true iff the XML has the specified metadata attribute.
See Also:
Builder.hasMetaAttribute(String)

removeMetaAttribute

public void removeMetaAttribute(String name)
Remove a metadata attribute.

Specified by:
removeMetaAttribute in interface Builder
Parameters:
name - The name of the attribute.

appendMetadataElement

public void appendMetadataElement(String eName,
                                  Map<String,String> attributes)
                           throws XBRLException
Appends a child element to the root metadata element.

Specified by:
appendMetadataElement in interface Builder
Parameters:
eName - Name of the element to be added (no namespaces are used).
attributes - A map from attribute name keys to attribute values.
Throws:
XBRLException - if the metadata element cannot be appended.

removeMetadataElement

public void removeMetadataElement(String eName,
                                  HashMap<String,String> attributes)
                           throws XBRLException
Removes a child element from the metadata root element by specifying the name of the child and the value of the element's text content and/or the value of a named attribute. All specified information must match for the deletion to succeed.

Specified by:
removeMetadataElement in interface Builder
Parameters:
eName - Name of the element to be added (no namespaces are used).
attributes - A hashmap from attribute name keys to attribute values.
Throws:
XBRLException - if the metadata element cannot be removed.

Get Java XBRL API implementation at SourceForge.net.