com.ihr.xbrl.om
Class XBRLDocument

java.lang.Object
  extended by com.ihr.xbrl.om.XMLFragment
      extended by com.ihr.xbrl.om.XMLDocumentURI
          extended by com.ihr.xbrl.om.XBRLDocument
All Implemented Interfaces:
XBRLRelationshipPoint, XBRLDTSDocument, XMLHasParent, java.lang.Cloneable, javax.xml.namespace.NamespaceContext
Direct Known Subclasses:
XBRLInstance, XBRLLinkbase, XBRLTaxonomy

public abstract class XBRLDocument
extends XMLDocumentURI

Contains the Properties of the object 2.2.2 XBRL Document Information Item The [Document URI] property is provided by the parent class XMLDocumentURI The [Document Information Item] property is provided by the root class XMLFragment The [Additional Properties] Properties are provided by classes derived by extension of this class

Author:
Ignacio

Field Summary
static int INSTANCE
           
static int IXBRL
           
static int LINKBASE
           
static int TAXONOMY
           
 
Fields inherited from class com.ihr.xbrl.om.XMLFragment
CONCEPT_LABEL, CONCEPT_QNAME, EMPTYRELATIONSHIPSITERATORINSTANCE, EMPTYXMLFRAGMENTITERATORINSTANCE, FACT_CONCEPT_DATATYPE, FACT_CONCEPT_LABEL, FACT_QNAME, idQName, NO_POSITION, OrderComparator, PERIOD_TYPE, PERIOD_VALUE, SHORT_TEXT, SOURCE_DOCUMENT, XPATH, XPOINTER
 
Constructor Summary
XBRLDocument(DTSContainer dts, javax.xml.transform.Source xmlSource)
          Creates an XBRLDocument form a Source object that can be used to obtain the XML nodes of the document content.
 
Method Summary
 void addExtendedLink(XBRLExtendedLink newExtendedLink)
           
 boolean addIdOfElement(XMLFragment newElement)
          Adds the id of newElement to the set of IDs stored in this document.
 boolean addIdOfElement(XMLFragment newElement, java.lang.String id)
          Adds the id of newElement to the set of IDs stored in this document.
 void addParent(XBRLDocument parent)
          Add a new XBRLDocument as parent of this document
 void changeElementId(XMLFragment newEl, java.lang.String oldId, java.lang.String newId)
          Changes the key of an element in the internal itemsById hashtable but does not change the id on the target element.
 void changeExtendedLinkKey(net.sf.saxon.s9api.XdmNode oldKey, net.sf.saxon.s9api.XdmNode newKey, XBRLExtendedLink link)
           
 void clear()
          Frees-up used memory This method should not be invoqued on live objects in the DTS.
static XMLDocumentURI createDocument(DTSContainer dts, java.net.URI baseURI, java.net.URI theURI, boolean addToCache, XBRLDTSDocument parent)
          Creates a Document, (instance, taxonomy or linkbase) by accessing the root element and looking at the document type.
static XMLDocumentURI createDocument(DTSContainer dts, java.net.URI baseURI, java.net.URI theURI, javax.xml.transform.Source source, boolean addToCache, XBRLDTSDocument parent)
          Creates a Document, (instance, taxonomy or linkbase) by accessing the root element and looking at the document type if the document is not a linkbase, schema or xbrl instance returns null.
static XMLDocumentURI createDocument(XMLDocumentURI node, boolean addToCache)
          Transforms the XMLDocumentURI in the node parameter into a XBRLDocument Linkbase, Taxonomy or Instance depending on the root node
 void delParent(XBRLDocument parent)
           
abstract  void discoverDTS(XBRLDTSDocument parent)
          All derived classes MUST implement this method and provide the functionality according to section 3.2 of the XBRL 2.1 specification
 boolean equals(java.lang.Object oe)
          Sets a new XPathFunctionResolver for this object
abstract  org.jdom.Document generateDocNode(boolean relativize, java.net.URI base)
          This class has to be implemented by objects derived from XBRLDocument and must return a org.jdom.Document node with the content of this XBRLDocument object
 java.util.Iterator<java.lang.String> getAllUsedIds()
          This method returns an iterator over all ids used by elements in this document
 java.util.Collection<java.lang.String> getComments()
          Access to the comments in the file
 net.sf.saxon.s9api.XdmNode getDocument()
          Returns the surrounding XML Node
 void getDTS()
          Launches the rules for DTSDiscovery process that will eventually add more objects to the DTSContainer
abstract  int getDTSDocumentType()
          Returns the type of DTS Document
abstract  java.lang.String getDTSDocumentTypeName()
           
 XMLFragment getElementById(java.lang.String id)
          This method returns the XMLFragment associated to the id received as a parameter.
 XBRLExtendedLink getExtendedLink(net.sf.saxon.s9api.XdmNode key)
           
 java.util.Iterator<XBRLExtendedLink> getExtendedLinks()
          Returns an iterator over all extended links on this container.
 java.util.Iterator<XBRLExtendedLink> getExtendedLinks(XBRLRoleType role)
          Returns an iterator over all extended links on this container filtered by the specific role type indicated in the role parameter.
 java.util.Iterator<XBRLDocument> getParents()
          Access to the [Parents] property
 int hashCode()
           
 boolean isIdUsed(java.lang.String id)
          This method returns true if the id indicated as a parameter corresponds to an XMLFragment in this XBRLDocument
static void moveNamespacesUp(org.jdom.Document jdomDocument)
          Internal method used during serialization of XML files.
abstract  void readInfoset()
          Read all structures that builds the infoset
 void removeExtendedLink(XBRLExtendedLink link)
           
 void removeIdOfElement(XMLFragment element)
           
 void save(boolean relativize)
          Save the file to the indicated document URI Directories in the path of the file name are created automatically
 void setComments(java.util.Collection<java.lang.String> fileComments)
          Sets a new collection of comments for this file.
 void setDocumentAndReload(net.sf.saxon.s9api.XdmNode node)
          This method is called by the XMLFragment object each time the surrounding XdmNode object is set.
 void updateXML(boolean relativize)
          Updates the XML content of the XBRLDocument so the next call to save or to XdmNode getDocument() will obtain a fresh copy with all changes made in the object library.
 
Methods inherited from class com.ihr.xbrl.om.XMLDocumentURI
addChild, delChild, generateLocatorToDocument, getBase, getChildren, getDocumentURI, getDTSKey, getLocalFile, isInDTS, setURI, validate
 
Methods inherited from class com.ihr.xbrl.om.XMLFragment
addAttribute, addChild, addFromRelationship, addNamespace, addNamespace, addToRelationship, addXMLChild, changeBase, checkBase, clone, clone, delAttribute, delAttribute, equalXdmValues, evaluateBoolean, evaluateList, evaluateNode, evaluateNumber, evaluateString, generateId, generateNode, generateNodeNamespacesAndAttributes, generateNodeValue, generatePrefix, getAttribute, getAttributeQNameValue, getAttributes, getAttributes, getAttributeValue, getBase, getBaseURI, getBooleanValue, getChild, getContainer, getDeclaredNamespaces, getElements, getFragment, getFriendlyName, getFriendlyName, getFromRelationships, getFromRelationships, getFromRelationships, getId, getLang, getNamespaceURI, getNodeName, getNumberOfElements, getNumberOfFromRelationships, getNumberOfToRelationships, getOrGenerateId, getParent, getPrefix, getPrefixes, getQNameValue, getRelationshipsBases, getRelationshipsChain, getRelationshipTypes, getStaticNamespace, getStringValue, getToRelationships, getToRelationships, getToRelationships, getValue, getXPathNamespaceContext, getXPathToNode, getXPathToRoot, getXPointerElementScheme, getXPointerElementScheme, getXPointerShorthandScheme, getXPointerToNode, isNamespaceDefined, objEquals, objHashCode, qNameToString, removeAttribute, removeChild, removeChild, removeFromRelationship, removeToRelationship, removeXMLChild, resetElements, resetHash, resolveHRef, resolveHRef, s_equal2, s_equal2, setAttributes, setBase, setDocument, setElements, setId, setLang, setNamespaceContext, setNamespaces, setNode, setNodeName, setParent, setValue, setValue, setVariablesDefined, toString, valueEquals, xEqual
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

INSTANCE

public static final int INSTANCE
See Also:
Constant Field Values

TAXONOMY

public static final int TAXONOMY
See Also:
Constant Field Values

LINKBASE

public static final int LINKBASE
See Also:
Constant Field Values

IXBRL

public static final int IXBRL
See Also:
Constant Field Values
Constructor Detail

XBRLDocument

public XBRLDocument(DTSContainer dts,
                    javax.xml.transform.Source xmlSource)
             throws net.sf.saxon.s9api.SaxonApiException
Creates an XBRLDocument form a Source object that can be used to obtain the XML nodes of the document content.

This creator just creates the XBRLDocument and passes sets the document content to the nodes read from the Source

Parameters:
dts - The DTSContainer under which the document will be created
xmlSource - the XML Source
Throws:
net.sf.saxon.s9api.SaxonApiException - in case of problems reading the source document
Method Detail

getDocument

public net.sf.saxon.s9api.XdmNode getDocument()
Description copied from class: XMLFragment
Returns the surrounding XML Node

Overrides:
getDocument in class XMLFragment
Returns:
NodeInfo

setDocumentAndReload

public void setDocumentAndReload(net.sf.saxon.s9api.XdmNode node)
                          throws XBRLInconsistentDTSException,
                                 com.rs.lic.LicenseVerificationException
Description copied from class: XMLFragment
This method is called by the XMLFragment object each time the surrounding XdmNode object is set. This happens internally by the XBRL API after XML Schema validation is performed so the surrounding XML nodes acquire type information.

Overwrite this method in parent objects in order to refresh objects that depends on the surrounding XML nodes.

Overrides:
setDocumentAndReload in class XMLFragment
Parameters:
node - the new XdmNode
Throws:
XBRLInconsistentDTSException
com.rs.lic.LicenseVerificationException

equals

public boolean equals(java.lang.Object oe)
Description copied from class: XMLFragment
Sets a new XPathFunctionResolver for this object

Overrides:
equals in class XMLDocumentURI

hashCode

public int hashCode()
Overrides:
hashCode in class XMLDocumentURI

createDocument

public static XMLDocumentURI createDocument(DTSContainer dts,
                                            java.net.URI baseURI,
                                            java.net.URI theURI,
                                            boolean addToCache,
                                            XBRLDTSDocument parent)
                                     throws DTSDiscoveryException,
                                            com.rs.lic.LicenseVerificationException
Creates a Document, (instance, taxonomy or linkbase) by accessing the root element and looking at the document type. If the document is not a linkbase schema or xbrl instance returns null.

The Document may not be ever part of any DTS.

The Document is first obtained from the cache. If it is not there, then it is loaded from the URI or Source and stored into the cache.

The following documents are ignored and this functions returns null.

Parameters:
dts - DTSContainer for the new document
theURI - URI of the document to generate
addToCache - - boolean indicating if the new document will be added to the cache or not
Returns:
XMLDocumentURI document from the cache or from the URI.
Throws:
DTSDiscoveryException
com.rs.lic.LicenseVerificationException

createDocument

public static XMLDocumentURI createDocument(DTSContainer dts,
                                            java.net.URI baseURI,
                                            java.net.URI theURI,
                                            javax.xml.transform.Source source,
                                            boolean addToCache,
                                            XBRLDTSDocument parent)
                                     throws DTSDiscoveryException,
                                            com.rs.lic.LicenseVerificationException
Creates a Document, (instance, taxonomy or linkbase) by accessing the root element and looking at the document type if the document is not a linkbase, schema or xbrl instance returns null.

The Document may not be part of any DTS.

The Document is first obtained from the cache. If it is not there, then it is loaded from the URI and stored into the cache.

the source parameter is an javax.xml.transform.Source object from which the document will be generated

Parameters:
dts -
theURI -
source -
addToCache -
parent -
Returns:
XMLDocumentURI object
Throws:
DTSDiscoveryException
com.rs.lic.LicenseVerificationException
Since:
2.6.4

createDocument

public static XMLDocumentURI createDocument(XMLDocumentURI node,
                                            boolean addToCache)
                                     throws com.rs.lic.LicenseVerificationException,
                                            DTSDiscoveryException
Transforms the XMLDocumentURI in the node parameter into a XBRLDocument Linkbase, Taxonomy or Instance depending on the root node

Parameters:
node - the XMLDocumentURI object to transform
addToCache - true if the document MUST be added to the cache
Returns:
a XMLDocumentURI
Throws:
com.rs.lic.LicenseVerificationException
DTSDicoveryException
DTSDiscoveryException

getDTSDocumentType

public abstract int getDTSDocumentType()
Returns the type of DTS Document

Returns:
DTSDocument.INSTANCE, DTSDocument.TAXONOMY or DTSDocument.LINKBASE

getDTSDocumentTypeName

public abstract java.lang.String getDTSDocumentTypeName()

discoverDTS

public abstract void discoverDTS(XBRLDTSDocument parent)
                          throws DTSDiscoveryException,
                                 com.rs.lic.LicenseVerificationException
All derived classes MUST implement this method and provide the functionality according to section 3.2 of the XBRL 2.1 specification

Specified by:
discoverDTS in interface XBRLDTSDocument
Overrides:
discoverDTS in class XMLDocumentURI
Throws:
DTSDiscoveryException
com.rs.lic.LicenseVerificationException

readInfoset

public abstract void readInfoset()
                          throws XBRLValidationException
Read all structures that builds the infoset

Throws:
XBRLValidationException

getDTS

public void getDTS()
            throws DTSDiscoveryException,
                   com.rs.lic.LicenseVerificationException
Launches the rules for DTSDiscovery process that will eventually add more objects to the DTSContainer

Throws:
DTSDiscoveryException
com.rs.lic.LicenseVerificationException

getExtendedLinks

public java.util.Iterator<XBRLExtendedLink> getExtendedLinks()
Returns an iterator over all extended links on this container. If the container may be an XBRLInstance, an XBRLTaxonomy or an XBRLLinkbase.

Returns:
Iterator<XBRLExtendedLink> instance

getExtendedLinks

public java.util.Iterator<XBRLExtendedLink> getExtendedLinks(XBRLRoleType role)
Returns an iterator over all extended links on this container filtered by the specific role type indicated in the role parameter. If the container may be an XBRLInstance, an XBRLTaxonomy or an XBRLLinkbase.

Parameters:
role - the XBRLRoleType for filtering
Returns:
Iterator<XBRLExtendedLink> instance

getExtendedLink

public XBRLExtendedLink getExtendedLink(net.sf.saxon.s9api.XdmNode key)
                                 throws DTSDiscoveryException
Throws:
DTSDiscoveryException

changeExtendedLinkKey

public void changeExtendedLinkKey(net.sf.saxon.s9api.XdmNode oldKey,
                                  net.sf.saxon.s9api.XdmNode newKey,
                                  XBRLExtendedLink link)

addExtendedLink

public void addExtendedLink(XBRLExtendedLink newExtendedLink)
Parameters:
newExtendedLink -

removeExtendedLink

public void removeExtendedLink(XBRLExtendedLink link)
Parameters:
link -

getParents

public java.util.Iterator<XBRLDocument> getParents()
Access to the [Parents] property

Returns:
Iterator

addParent

public void addParent(XBRLDocument parent)
Add a new XBRLDocument as parent of this document

Parameters:
parent -

delParent

public void delParent(XBRLDocument parent)

addIdOfElement

public boolean addIdOfElement(XMLFragment newElement)
Adds the id of newElement to the set of IDs stored in this document. Two elements cannot have the same ID because this is forbidden according to XML rules.

Don't call this method from inside XMLFragment.getId() or methods overridden by subclasses. Call the addIdOfElement(XMLFragment, String) method instead.

Parameters:
newElement - element from which the ID will be obtained
Returns:
boolean, true if the element is new or is a substitute of previous element and contains an id and and has been added or has replaced previous element. false if the element already exist and is the same element or has no id
Throws:
XBRLDuplicateException - if the ID already exist in the instance

addIdOfElement

public boolean addIdOfElement(XMLFragment newElement,
                              java.lang.String id)
Adds the id of newElement to the set of IDs stored in this document. Two elements cannot have the same ID because this is forbidden according to XML rules.

Parameters:
newElement - element to be added. The ID will not be obtained from the node
id - to be set for this XMLFragment. The ID must be the real id set on this element node in the id attribute
Returns:
boolean, true if the element is new or is a substitute of previous element and contains an id and and has been added or has replaced previous element. false if the element already exist and is the same element or has no id

removeIdOfElement

public void removeIdOfElement(XMLFragment element)
Parameters:
element -

changeElementId

public void changeElementId(XMLFragment newEl,
                            java.lang.String oldId,
                            java.lang.String newId)
                     throws XBRLInconsistentDTSException
Changes the key of an element in the internal itemsById hashtable but does not change the id on the target element.

Parameters:
newEl - element definition
oldId -
newId - the new ID of the element in the table
Throws:
XBRLInconsistentDTSException

getAllUsedIds

public java.util.Iterator<java.lang.String> getAllUsedIds()
This method returns an iterator over all ids used by elements in this document

Returns:
Iterator<String>
Since:
2.6.5

isIdUsed

public boolean isIdUsed(java.lang.String id)
This method returns true if the id indicated as a parameter corresponds to an XMLFragment in this XBRLDocument

Parameters:
id - String
Returns:
boolean value
Since:
2.6.5

getElementById

public XMLFragment getElementById(java.lang.String id)
This method returns the XMLFragment associated to the id received as a parameter.

Subclasses of this class may contain methods that returns the appropriate object for an id. Use this method as a last resort if you don't know or you don't care about the returned object type.

Parameters:
id - string, the id of the element to retrieve
Returns:
an XMLFragment or null if nothing in this document is indexed under that id
Since:
2.6.5

save

public void save(boolean relativize)
          throws XBRLSerializationException
Save the file to the indicated document URI Directories in the path of the file name are created automatically

Parameters:
relativize - true if elements inside the file would be relative to the file or base URI
Throws:
java.io.IOException
XBRLValidationException
XBRLSerializationException

updateXML

public void updateXML(boolean relativize)
               throws XBRLSerializationException
Updates the XML content of the XBRLDocument so the next call to save or to XdmNode getDocument() will obtain a fresh copy with all changes made in the object library.

Parameters:
relativize - boolean value indicating if URLs (in locators, linkbaseRefs, etc...) will be relativized using the document URL as a base URL.
Throws:
XBRLSerializationException
Since:
2.6.12

moveNamespacesUp

public static void moveNamespacesUp(org.jdom.Document jdomDocument)
Internal method used during serialization of XML files. Not intented to be used by applications Searches down the tree of nodes and move namespace declarations up to the root element if there are no conflicting namespace prefixes. Does not remove any namespace declaration because prefixes may be used inside text nodes

Parameters:
jdomDocument -

generateDocNode

public abstract org.jdom.Document generateDocNode(boolean relativize,
                                                  java.net.URI base)
                                           throws XBRLSerializationException
This class has to be implemented by objects derived from XBRLDocument and must return a org.jdom.Document node with the content of this XBRLDocument object

Parameters:
relativize - boolean indicating if all URIs must be relativized
base - URI the base uri to relativize other URIs
Returns:
org.jdom.Document
Throws:
XBRLValidationException
java.net.MalformedURLException
XBRLSerializationException

getComments

public java.util.Collection<java.lang.String> getComments()
Access to the comments in the file

Returns:
Collection

setComments

public void setComments(java.util.Collection<java.lang.String> fileComments)
Sets a new collection of comments for this file. The new comments will be serialized to the file during a call to the generateDocNode method.

Parameters:
fileComments - Collection

clear

public void clear()
           throws java.lang.Throwable
Description copied from class: XMLFragment
Frees-up used memory

This method should not be invoqued on live objects in the DTS. It is automatically invoqued by the API when an object is no longer used and referenced by other objects. It is save not to call it directly.

Specified by:
clear in interface XBRLDTSDocument
Overrides:
clear in class XMLDocumentURI
Throws:
java.lang.Throwable


Copyright 2006-2009 Reporting Standard S.L., C/ Torrecilla del Puerto 1, 28043, Madrid, Espaņa