XBRLAPI

A Java API for XBRL


org.xbrlapi.impl
Class XMLImpl

java.lang.Object
  extended by org.xbrlapi.impl.XMLImpl
All Implemented Interfaces:
Serializable, Comparable<XML>, XML
Direct Known Subclasses:
ErrorImpl, FragmentImpl, NonFragmentXMLImpl

public class XMLImpl
extends Object
implements XML

See Also:
Serialized Form

Field Summary
protected static org.apache.log4j.Logger logger
           
 
Constructor Summary
XMLImpl()
           
 
Method Summary
 void appendMetadataElement(String eName, Map<String,String> attributes)
          Appends a child element to the root metadata element.
 int compareTo(XML other)
          Comparison is based upon the fragment index.
 boolean equals(Object obj)
          Override the Object equals method to base equality on the fragment index.
protected  void finalize()
           
 Builder getBuilder()
          Get the fragment builder.
 Document getDocumentNode()
          Get the XML DOM Document for the fragment data.
 String getIndex()
          Get the index of the XML resource.
 String getMetaAttribute(String name)
          Get a fragment metadata attribute.
 Element getMetadataRootElement()
          Get the root element of the fragment metadata.
 Store getStore()
          Get the data store that manages this fragment.
 String getType()
          Get the Fragment type.
 int hashCode()
          Override the Object hashCode method to provide for equality comparisons that are based on the fragment index.
 boolean hasMetaAttribute(String name)
           
 boolean isa(Class<?> targetClass)
           
 boolean isa(String type)
           
 void removeMetaAttribute(String name)
          Removes 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.
 String serialize()
           
 void serialize(File file)
          Serializes the XML to the specified file.
 void serialize(OutputStream outputStream)
          Serializes the XML to the specified output stream.
 void setBuilder(Builder builder)
          Set the builder that constructs the fragment XML during parsing.
 void setIndex(String index)
          Set the fragment index.
 void setMetaAttribute(String name, String value)
          Set a fragment metadata attribute.
 void setResource(Element rootElement)
          Closes down the fragment builder and sets the data and metadata resources for the fragment.
 void setStore(Store store)
          Set the data store that manages this fragment.
 void updateInStore()
          Updates the data store to reflect the current state of this XML object.
 
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static final org.apache.log4j.Logger logger
Constructor Detail

XMLImpl

public XMLImpl()
Method Detail

finalize

protected void finalize()
                 throws Throwable
Overrides:
finalize in class Object
Throws:
Throwable

isa

public boolean isa(String type)
            throws XBRLException
Specified by:
isa in interface XML
Parameters:
type - The specified fragment type to test against.
Returns:
true if the fragment is an extension of the specified fragment type.
Throws:
XBRLException
See Also:
XML.isa(String)

isa

public boolean isa(Class<?> targetClass)
            throws XBRLException
Specified by:
isa in interface XML
Parameters:
targetClass - The specified XML resource subclass to test against.
Returns:
true if the fragment is an extension of the specified fragment type.
Throws:
XBRLException
See Also:
XML.isa(Class)

hashCode

public int hashCode()
Description copied from interface: XML
Override the Object hashCode method to provide for equality comparisons that are based on the fragment index.

Specified by:
hashCode in interface XML
Overrides:
hashCode in class Object
See Also:
Object.hashCode()

equals

public boolean equals(Object obj)
Description copied from interface: XML
Override the Object equals method to base equality on the fragment index.

Specified by:
equals in interface XML
Overrides:
equals in class Object
See Also:
Object.equals(java.lang.Object)

compareTo

public int compareTo(XML other)
              throws ClassCastException
Comparison is based upon the fragment index.

Specified by:
compareTo in interface Comparable<XML>
Throws:
ClassCastException
See Also:
Comparable.compareTo(Object o)

setResource

public void setResource(Element rootElement)
                 throws XBRLException
Description copied from interface: XML
Closes down the fragment builder and sets the data and metadata resources for the fragment. This should only be used by Store implementations at the point where a newly built fragment is stored.

Specified by:
setResource in interface XML
Parameters:
rootElement - The fragment data.
Throws:
XBRLException - If the builder cannot be shut down or if the resource cannot be set or is null.
See Also:
XML.setResource(Element)

getDocumentNode

public Document getDocumentNode()
Description copied from interface: XML
Get the XML DOM Document for the fragment data.

Specified by:
getDocumentNode in interface XML
Returns:
an XML DOM document for the fragment or null if none exists.
See Also:
XML.getDocumentNode()

setStore

public void setStore(Store store)
              throws XBRLException
Description copied from interface: XML
Set the data store that manages this fragment.

Specified by:
setStore in interface XML
Parameters:
store - The data store.
Throws:
XBRLException - if the data store has already been set.
See Also:
XML.setStore(Store)

setBuilder

public void setBuilder(Builder builder)
Description copied from interface: XML
Set the builder that constructs the fragment XML during parsing.

Specified by:
setBuilder in interface XML
Parameters:
builder - The builder object used to construct the fragment XML.
See Also:
XML.setBuilder(Builder)

getStore

public Store getStore()
Description copied from interface: XML
Get the data store that manages this fragment.

Specified by:
getStore in interface XML
Returns:
the data store that manages this fragment or null if the fragment has not been stored.
See Also:
XML.getStore()

getBuilder

public Builder getBuilder()
Description copied from interface: XML
Get the fragment builder. Note that the builder is null if the fragment has already been stored in a data store. TODO Should fragments hide the builder property?

Specified by:
getBuilder in interface XML
Returns:
the fragment builder or null if one is not available.
See Also:
XML.getBuilder()

getMetadataRootElement

public Element getMetadataRootElement()
Description copied from interface: XML
Get the root element of the fragment metadata.

Specified by:
getMetadataRootElement in interface XML
Returns:
an XML Element that is the root of the fragment metadata.
See Also:
XML.getMetadataRootElement()

getIndex

public String getIndex()
Description copied from interface: XML
Get the index of the XML resource. This is the name used for the XML resource in the data store.

Specified by:
getIndex in interface XML
See Also:
XML.getIndex()

setIndex

public void setIndex(String index)
              throws XBRLException
Description copied from interface: XML
Set the fragment index. Note that no checks are performed to ensure that the fragment index is unique within the data store. This method instantiates a fragment builder for fragments that do not have a resource property.

Specified by:
setIndex in interface XML
Throws:
XBRLException
See Also:
XML.setIndex(String)

getType

public String getType()
Description copied from interface: XML
Get the Fragment type. The fragment type is immutable. No public method is available to set the fragment type.

Specified by:
getType in interface XML
Returns:
The full class name of the fragment.
See Also:
XML.getType()

setMetaAttribute

public void setMetaAttribute(String name,
                             String value)
                      throws XBRLException
Description copied from interface: XML
Set a fragment metadata attribute.

Specified by:
setMetaAttribute in interface XML
Parameters:
name - the name of the attribute
value - the value to give to the metadata attribute
Throws:
XBRLException
See Also:
XML.setMetaAttribute(String, String)

removeMetaAttribute

public void removeMetaAttribute(String name)
                         throws XBRLException
Description copied from interface: XML
Removes a metadata attribute

Specified by:
removeMetaAttribute in interface XML
Parameters:
name - The name of the attribute to remove
Throws:
XBRLException
See Also:
XML.removeMetaAttribute(String)

getMetaAttribute

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

Specified by:
getMetaAttribute in interface XML
Parameters:
name - the name of the attribute.
Returns:
The value of the metadata attribute or null if none exists.
See Also:
XML.getMetaAttribute(String)

hasMetaAttribute

public boolean hasMetaAttribute(String name)
Specified by:
hasMetaAttribute in interface XML
Parameters:
name - the name of the attribute.
Returns:
true if the XML resource has a metadata attribute with the specfied name.
See Also:
XML.getMetaAttribute(String)

appendMetadataElement

public void appendMetadataElement(String eName,
                                  Map<String,String> attributes)
                           throws XBRLException
Description copied from interface: XML
Appends a child element to the root metadata element.

Specified by:
appendMetadataElement in interface XML
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
See Also:
XML.appendMetadataElement(String, Map)

removeMetadataElement

public void removeMetadataElement(String eName,
                                  HashMap<String,String> attributes)
                           throws XBRLException
Description copied from interface: XML
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 XML
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 no deletion happens.
See Also:
XML.removeMetadataElement(String, HashMap)

serialize

public void serialize(File file)
               throws XBRLException
Description copied from interface: XML
Serializes the XML to the specified file.

Specified by:
serialize in interface XML
Parameters:
file - The specified output file.
Throws:
XBRLException
See Also:
XML.serialize(File)

serialize

public void serialize(OutputStream outputStream)
               throws XBRLException
Description copied from interface: XML
Serializes the XML to the specified output stream.

Specified by:
serialize in interface XML
Parameters:
outputStream - The specified output stream.
Throws:
XBRLException
See Also:
XML.serialize(OutputStream)

serialize

public String serialize()
                 throws XBRLException
Specified by:
serialize in interface XML
Returns:
the XML as a string.
Throws:
XBRLException
See Also:
XML.serialize()

updateInStore

public void updateInStore()
                   throws XBRLException
Description copied from interface: XML
Updates the data store to reflect the current state of this XML object. If the XML object has not yet been stored then no action is taken. If there is a XML resource in the store with the same index, then that earlier version is first deleted from the data store.

Specified by:
updateInStore in interface XML
Throws:
XBRLException
See Also:
XML.updateInStore()

Get Java XBRL API implementation at SourceForge.net.