com.ihr.xbrl.om.instance

## Class XBRLContext

- java.lang.Object
- - com.ihr.xbrl.om.XMLFragment
  - - com.ihr.xbrl.om.instance.XBRLContext

- All Implemented Interfaces:
    HasAdditionalEqualityForReassignation, XBRLRelationshipPoint, Thinable, XBRLValidation, XMLHasParent, java.lang.Cloneable, javax.xml.namespace.NamespaceContext

      public class XBRLContext
      extends XMLFragment
      implements java.lang.Cloneable, XBRLValidation, Thinable

  This class represents the content of an XBRL Context.

  An XBRL Context contains:

  Content | Description
  --- | ---
  XBRLEntity | Content about the reporting entity
  XBRLPeriod | Content about the reporting period, instant or duration
  XBRLScenario | Content about the reporting scenario. Collection of XML nodes

  Author:
    Ignacio

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface com.ihr.xbrl.om.XBRLValidation

      `XBRLValidation.Direction`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static javax.xml.namespace.QName` | `contextNode` The QName of the XML element that is the container of context information.

    - ### Fields inherited from class com.ihr.xbrl.om.XMLFragment

      `CONCEPT_LABEL, CONCEPT_QNAME, EASY_TO_READ, ELEMENT_LABEL, EMPTYRELATIONSHIPSITERATORINSTANCE, EMPTYXMLFRAGMENTITERATORINSTANCE, FACT_CONCEPT_DATATYPE, FACT_CONCEPT_LABEL, FACT_QNAME, HIDE_COMMON_ACCURACY, idQName, NO_POSITION, OrderComparator, OrderComparator2, PERIOD_TYPE, PERIOD_VALUE, SHORT_TEXT, SOURCE_DOCUMENT, XPATH, XPOINTER`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `XBRLContext(DTSContainer dts, XBRLEntity entity, XBRLPeriod period, XBRLScenario scenario)` Creates a new context with the supplied entity, period and scenario.
    `XBRLContext(XBRLContext other)` Creates a new context as a copy or clone of the context supplied as a parameter The new context will have null as parent instance.
    `XBRLContext(XBRLInstance parent, XBRLEntity entity, XBRLPeriod period, XBRLScenario scenario)` Creates a new context with the supplied entity, period and scenario and set the parent to the parent instance.
    `XBRLContext(XBRLInstance parent, net.sf.saxon.s9api.XdmNode root)` Creates a new context with the supplied XdmNode.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addXMLChild(XMLHasParent newChild)` Adds the xml child.
    `void` | `clear()` Frees-up used memory This method should not be invoqued on live objects in the DTS.
    `XBRLContext` | `clone()`
    `XBRLContext` | `clone(DTSContainer newDTS)` Clone.
    `boolean` | `equals(java.lang.Object other)` Evaluates c-equality of two contexts according to the XBRL 2.1 spec The context IDs may be different and are not compared
    `org.jdom.Element` | `generateNode(boolean relativize, java.net.URI base)` Serializes to a jdom Element the representation of the properties of this Information Item This method should be called from classes derived from this class
    `java.util.Iterator<XMLFragment>` | `getElements()` For complex type resources this returns an iterator with all children XML fragments This method may be overwriten by other classes in the hierarchy.
    `XBRLEntity` | `getEntity()` Obtains the entity associated with this context or null.
    `java.lang.String` | `getFriendlyName()` Returns a string description that represents the element content in a form that users can understand.
    `java.lang.String` | `getFriendlyName(int modifiers, LabelsProvider lp)` Returns a string description that represents the element content in a form that users can understand.
    `java.lang.String` | `getFriendlyNameOnlyId()` Gets the friendly name only id.
    `XBRLInstance` | `getParent()` The parent XMLFragment node of this XMLFragment node.
    `XBRLPeriod` | `getPeriod()` obtains the period of this context.
    `XBRLScenario` | `getScenario()` Returns the scenario for this context.
    `XBRLValidationReport` | `getValidationReport()` Access to the last stored validation report.
    `net.sf.saxon.s9api.XdmValue` | `getValue()` Returns the value of this node.
    `int` | `hashCode()`
    `void` | `invalidate()` Invalidates the XBRLFact for XBRL validation.
    `boolean` | `invalidate(XBRLValidation.Direction dir)` Invalidates this object and the elements in the XML tree according with the parameter in dir This method is used by GUI tools that requires to reset validation before a manual validation cycle is started.
    `boolean` | `isOnValidation()` When validation is a recursive process, this function returns true if the object going to be validated is already under validation.
    `void` | `removeXMLChild(XMLHasParent child)` Removes the xml child.
    `boolean` | `s_equal2(java.lang.Object other)` Resolves s_equal2 comparison of this node against the other node.
    `void` | `setEntity(XBRLEntity entity)` Sets the entity for this context this method resets validation of the context.
    `void` | `setId(java.lang.String id)` Sets the content of the id attribute of this element the ID MUST not have any space, but null is allowed and removes an id from an XML Fragment.
    `void` | `setParent(XMLHasParent instance)` Sets the parent of this context to the instance document specified in the parameter.
    `void` | `setPeriod(XBRLPeriod period)` Sets the period of this context this method resets validation status of this context.
    `void` | `setScenario(XBRLScenario scenario)` Sets the new scenario for this context using this method resets validation flag.
    `void` | `thin()` Removes from memory all objects that can be obtained back from the surrounding XML nodes or can be calculated again from other sources.
    `XBRLValidationReport` | `validate(XBRLPlugInProcessor proc)` Executes validation on the instance object and returns a validation report.

    - ### Methods inherited from class com.ihr.xbrl.om.XMLFragment

      `addAttribute, addChild, addFromRelationship, addNamespace, addNamespace, addToRelationship, changeBase, checkBase, delAttribute, delAttribute, equalXdmValues, evaluateBoolean, evaluateList, evaluateNode, evaluateNumber, evaluateString, generateId, generateNodeNamespacesAndAttributes, generateNodeValue, generatePrefix, getAllAttributes, getAttribute, getAttributeBooleanValue, getAttributeQNameValue, getAttributes, getAttributes, getAttributeStringValue, getAttributeValue, getBase, getBase, getBaseURI, getBooleanValue, getChild, getContainer, getContainerDocumentURI, getDeclaredNamespaces, getDocument, getElementsHashCode, getFragment, getFromRelationships, getFromRelationships, getFromRelationships, getFromRelationships, getFromRelationships, getGenericLabelText, getId, getLang, getNamespaceURI, getNodeName, getNumberOfAttributes, getNumberOfElements, getNumberOfFromRelationships, getNumberOfToRelationships, getOrGenerateId, getPrefix, getPrefixes, getQNameValue, getRelationshipsBases, getRelationshipsChain, getRelationshipTypes, getStaticContext, getStaticNamespace, getStringValue, getToolTipText, getToRelationships, getToRelationships, getToRelationships, getToRelationships, getToRelationships, getXPathExecutable, getXPathNamespaceContext, getXPathToNode, getXPathToRoot, getXPointerElementScheme, getXPointerElementScheme, getXPointerShorthandScheme, getXPointerToNode, isDead, isNamespaceDefined, isXdmDocumentAttached, objEquals, objHashCode, qNameToString, removeAttribute, removeChild, removeChild, removeFromRelationship, removeToRelationship, resetElements, resetHash, resolve_equal2, resolveHRef, resolveHRef, s_equal2, s_equal2, setAttributes, setBase, setDocument, setDocumentAndReload, setElements, setLang, setNamespaceContext, setNamespaces, setNode, setNodeName, setRegenerateNodeIfnotFound, setValue, setValue, setVariablesDefined, size, toString, valueEquals, xEqual`

    - ### Methods inherited from class java.lang.Object

      `getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### contextNode

          public static final javax.xml.namespace.QName contextNode

      The QName of the XML element that is the container of context information.

  - ### Constructor Detail

    - #### XBRLContext

          public XBRLContext(XBRLInstance parent,
                     net.sf.saxon.s9api.XdmNode root)
                      throws XBRLInconsistentDTSException

      Creates a new context with the supplied XdmNode.
      Parameters:
        `parent` - - The XBRLInstance object that is the parent of this context
        `root` - - The XdmNode for this context
      Throws:
        `XBRLInconsistentDTSException` - the XBRL inconsistent dts exception

    - #### XBRLContext

          public XBRLContext(DTSContainer dts,
                     XBRLEntity entity,
                     XBRLPeriod period,
                     XBRLScenario scenario)

      Creates a new context with the supplied entity, period and scenario. The content parent will not be set so it will be null
      Parameters:
        `dts` - - The container DTS, MUST not be null
        `entity` - - The entity, may be null
        `period` - - The period, may be null
        `scenario` - - The scenario, may be null

    - #### XBRLContext

          public XBRLContext(XBRLInstance parent,
                     XBRLEntity entity,
                     XBRLPeriod period,
                     XBRLScenario scenario)

      Creates a new context with the supplied entity, period and scenario and set the parent to the parent instance.
      Parameters:
        `parent` - - The parent XBRLInstance document
        `entity` - - The entity, may be null
        `period` - - The period, may be null
        `scenario` - - The scenario, may be null

    - #### XBRLContext

          public XBRLContext(XBRLContext other)

      Creates a new context as a copy or clone of the context supplied as a parameter The new context will have null as parent instance.
      Parameters:
        `other` - the context to clone

  - ### Method Detail

    - #### 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.

      Overrides:
        `clear` in class `XMLFragment`
      Throws:
        `java.lang.Throwable` - the throwable

    - #### thin

          public void thin()

      Description copied from interface: `Thinable`
      Removes from memory all objects that can be obtained back from the surrounding XML nodes or can be calculated again from other sources. Calling this method should reduce the memory footprint of this node
      Specified by:
        `thin` in interface `Thinable`
      Overrides:
        `thin` in class `XMLFragment`

    - #### setId

          public void setId(java.lang.String id)
                     throws XBRLInconsistentDTSException

      Description copied from class: `XMLFragment`
      Sets the content of the id attribute of this element the ID MUST not have any space, but null is allowed and removes an id from an XML Fragment. This method may be overwritten by other classes that require storing an indexed table of elements and IDs in order to prevent duplicate IDs to exist
      Overrides:
        `setId` in class `XMLFragment`
      Parameters:
        `id` - the new ID
      Throws:
        `XBRLInconsistentDTSException` - if the id is not lexicographically valid

    - #### clone

          public XBRLContext clone()

      Overrides:
        `clone` in class `XMLFragment`

    - #### clone

          public XBRLContext clone(DTSContainer newDTS)

      Description copied from class: `XMLFragment`
      Clone.
      Overrides:
        `clone` in class `XMLFragment`
      Parameters:
        `newDTS` - the new dts
      Returns:
        the XML fragment

    - #### equals

          public boolean equals(java.lang.Object other)

      Evaluates c-equality of two contexts according to the XBRL 2.1 spec The context IDs may be different and are not compared
      Overrides:
        `equals` in class `XMLFragment`
      Parameters:
        `other` - the other
      Returns:
        true, if successful

    - #### s_equal2

          public boolean s_equal2(java.lang.Object other)

      Description copied from class: `XMLFragment`
      Resolves s_equal2 comparison of this node against the other node.
      Overrides:
        `s_equal2` in class `XMLFragment`
      Parameters:
        `other` - The other node (preferably an XMLFragment) that contains a non null NodeInfo document.
      Returns:
        boolean

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `XMLFragment`

    - #### getPeriod

          public XBRLPeriod getPeriod()

      obtains the period of this context.
      Returns:
        the period object or null if not set or it cannot be created from the supplied node

    - #### setPeriod

          public void setPeriod(XBRLPeriod period)

      Sets the period of this context this method resets validation status of this context.
      Parameters:
        `period` - the new period

    - #### getEntity

          public XBRLEntity getEntity()

      Obtains the entity associated with this context or null.
      Returns:
        an XBRLEntity object

    - #### setEntity

          public void setEntity(XBRLEntity entity)

      Sets the entity for this context this method resets validation of the context.
      Parameters:
        `entity` - the new entity

    - #### getScenario

          public XBRLScenario getScenario()

      Returns the scenario for this context. this method never returns null. It returns a newly created empty scenario if the scenario was not specified
      Returns:
        an XBRLScenario object

    - #### setScenario

          public void setScenario(XBRLScenario scenario)

      Sets the new scenario for this context using this method resets validation flag.
      Parameters:
        `scenario` - the new scenario

    - #### generateNode

          public org.jdom.Element generateNode(boolean relativize,
                                      java.net.URI base)
                                        throws XBRLSerializationException

      Description copied from class: `XMLFragment`
      Serializes to a jdom Element the representation of the properties of this Information Item This method should be called from classes derived from this class
      Overrides:
        `generateNode` in class `XMLFragment`
      Parameters:
        `relativize` - boolean indicating if URIs should be relativized to the base URI (see next argument)
        `base` - the URI to which some attributes of this object should be relativided
      Returns:
        a clone of the surrounding jdom Element so it can be incorporated into multiple trees
      Throws:
        `XBRLSerializationException` - the XBRL serialization exception

    - #### getValue

          public net.sf.saxon.s9api.XdmValue getValue()

      Description copied from class: `XMLFragment`
      Returns the value of this node. If the value has been set to a jdom node then this function returns null If getDocument() is null then this function returns an empty sequence If getDocument() is not null this function tries to return an atomic value this function should be overridden by objects in this API
      Overrides:
        `getValue` in class `XMLFragment`
      Returns:
        a net.sf.saxon.s9api.XdmValue

    - #### setParent

          public void setParent(XMLHasParent instance)
                         throws XBRLInconsistentDTSException

      Sets the parent of this context to the instance document specified in the parameter.
      Specified by:
        `setParent` in interface `XMLHasParent`
      Overrides:
        `setParent` in class `XMLFragment`
      Parameters:
        `instance` - XBRLInstance
      Throws:
        `XBRLInconsistentDTSException` - if the context contains facts in a previous unattached instance

    - #### addXMLChild

          public void addXMLChild(XMLHasParent newChild)
                           throws XBRLInconsistentDTSException

      Description copied from interface: `XMLHasParent`
      Adds the xml child.
      Specified by:
        `addXMLChild` in interface `XMLHasParent`
      Overrides:
        `addXMLChild` in class `XMLFragment`
      Parameters:
        `newChild` - the child
      Throws:
        `XBRLInconsistentDTSException` - the XBRL inconsistent dts exception

    - #### removeXMLChild

          public void removeXMLChild(XMLHasParent child)

      Description copied from interface: `XMLHasParent`
      Removes the xml child.
      Specified by:
        `removeXMLChild` in interface `XMLHasParent`
      Overrides:
        `removeXMLChild` in class `XMLFragment`
      Parameters:
        `child` - the child

    - #### getParent

          public XBRLInstance getParent()

      Description copied from class: `XMLFragment`
      The parent XMLFragment node of this XMLFragment node.

      For XBRLAttribute nodes, the parent is the element node.

      For Document nodes the returned value is null

      For Embedded document nodes, the returned value is the parent element node.

      Specified by:
        `getParent` in interface `XMLHasParent`
      Overrides:
        `getParent` in class `XMLFragment`
      Returns:
        the parent XMLFragment possible parents are: XBRLItem, XBRLTuple, XBRLImport, XBRLLinkbase, XBRLExtendedLink, XBRLDocumentation, XBRLRelationship, XBRLResource.

    - #### getElements

          public java.util.Iterator<XMLFragment> getElements()

      Description copied from class: `XMLFragment`
      For complex type resources this returns an iterator with all children XML fragments This method may be overwriten by other classes in the hierarchy.
      Overrides:
        `getElements` in class `XMLFragment`
      Returns:
        Iterator

    - #### getFriendlyName

          public java.lang.String getFriendlyName()

      Description copied from class: `XMLFragment`
      Returns a string description that represents the element content in a form that users can understand. This method may be overridden by parent classes.

      Remarks, this method may return very long names not suitable for user interface

      Overrides:
        `getFriendlyName` in class `XMLFragment`
      Returns:
        Non empty String. Internationalization is enabled

    - #### getFriendlyName

          public java.lang.String getFriendlyName(int modifiers,
                                         LabelsProvider lp)

      Description copied from class: `XMLFragment`
      Returns a string description that represents the element content in a form that users can understand. This method may be override by parent classes.

      This function accepts flags that are defined as constants in XMLFragment in order to modify the output.

      - `XMLFragment.XPOINTER` includes the element position in the source file using the XPointer specification. Note, if the document is created from objects the value may not be available
      - `XMLFragment.XPATH` includes the element position in the source file using XPATH. Note, if the document is created from objects the value may not be available
      - `XMLFragment.NO_POSITION` does not include the element position in the source file.
      - `XMLFragment.CONCEPT_QNAME` for XBRLItem, XBRLTuple and XMLElementDefinition.
      - `XMLFragment.CONCEPT_LABEL` for XBRLItem and XBRLTuple.
      - `XMLFragment.FACT_QNAME` for facts.
      - `XMLFragment.FACT_CONCEPT_LABEL` for facts.
      - `XMLFragment.SHORT_TEXT` for resources, returns the resource text, id or xlink:label
      - `XMLFragment.EASY_TO_READ` for contexts, returns the context date and dimensions in a user friendly text representation
      Overrides:
        `getFriendlyName` in class `XMLFragment`
      Parameters:
        `modifiers` - integer
        `lp` - the lp
      Returns:
        Non empty String. Internationalization is enabled

    - #### getFriendlyNameOnlyId

          public java.lang.String getFriendlyNameOnlyId()

      Gets the friendly name only id.
      Returns:
        the friendly name only id

    - #### getValidationReport

          public XBRLValidationReport getValidationReport()

      Description copied from interface: `XBRLValidation`
      Access to the last stored validation report.
      Specified by:
        `getValidationReport` in interface `XBRLValidation`
      Returns:
        XBRLValidationReport or null if the object has not been validated or no errors exists

    - #### validate

          public XBRLValidationReport validate(XBRLPlugInProcessor proc)

      Description copied from interface: `XBRLValidation`
      Executes validation on the instance object and returns a validation report.

      The validation result may be cached internally. A call to `XBRLValidation.invalidate(Direction)` clears the validation cache.

      Specified by:
        `validate` in interface `XBRLValidation`
      Parameters:
        `proc` - the processor under which the object is going to be validated. Note the same object can be validated on multiple processors.
      Returns:
        the validation report or null if no errors.

    - #### invalidate

          public void invalidate()

      Description copied from interface: `XBRLValidation`
      Invalidates the XBRLFact for XBRL validation.
      Specified by:
        `invalidate` in interface `XBRLValidation`

    - #### invalidate

          public boolean invalidate(XBRLValidation.Direction dir)

      Description copied from interface: `XBRLValidation`
      Invalidates this object and the elements in the XML tree according with the parameter in dir

      This method is used by GUI tools that requires to reset validation before a manual validation cycle is started.

      Specified by:
        `invalidate` in interface `XBRLValidation`
      Parameters:
        `dir` - see the `XBRLValidation.Direction` enumeration for more information.
      Returns:
        true, if successful

    - #### isOnValidation

          public boolean isOnValidation()

      Description copied from interface: `XBRLValidation`
      When validation is a recursive process, this function returns true if the object going to be validated is already under validation. This prevents a recursive loop to enter the same validation component in an infinite loop.
      Specified by:
        `isOnValidation` in interface `XBRLValidation`
      Returns:
        true if the document is under validation. Means, the validation has not finished.