com.ihr.xbrl.om.instance

## Class XBRLFact

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

- All Implemented Interfaces:
    HasAdditionalEqualityForReassignation, ObtainHistoryInterface, StoreHistoryInterface, XBRLRelationshipPoint, Thinable, XBRLValidation, XMLHasParent, java.lang.Cloneable, javax.xml.namespace.NamespaceContext
  Direct Known Subclasses:
    XBRLFactItem, XBRLFactTuple

      public abstract class XBRLFact
      extends XMLFragment
      implements XBRLValidation, StoreHistoryInterface

  Abstract class to represent a fact item in an instance document or inside a tuple. Concreate classes of this class are: XBRLFactItem and XBRLFactTuple
  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` | `nil` The Constant nil.

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

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addEvent(java.util.Date date, java.lang.String message)` Adds a new event at the indicated date with the specificed message.
    `void` | `addEvent(HistoricalEventInterface event)` Adds a new event as an instance of an HistoricalEventInterface.
    `void` | `addEvent(java.lang.String message)` Adds a new event at the time this method is called with the specified message.
    `void` | `clear()` Eliminates all this fact content.
    `XBRLFact` | `clone()`
    `XBRLFact` | `clone(DTSContainer newDTS)` Clone current fact but in a new DTSContainer.
    `static XBRLFact` | `createItemOrTupleInstance(DTSContainer dts, XBRLFactsList facts, net.sf.saxon.s9api.XdmNode node, int pos)` Creates a tupleInstance or a itemInstance depending on the node content.
    `static XBRLFact` | `createItemOrTupleInstance(XBRLFactsList facts, XMLElementDefinition el, XBRLContext ctx, XBRLUnit unit)` Creates a tupleInstance of a itemInstance depending on the data type of the el parameter and extra information provided in other parameters.
    `boolean` | `equals(java.lang.Object obj)` Sets a new XPathFunctionResolver for this object.
    `XBRLLocator` | `generateLocatorToNode(boolean relativize, java.net.URI base)` Generates a locator element pointing to the instantiated fact on the instance This is used during serialization of the instance document.
    `org.jdom.Element` | `generateNode(boolean relativize, java.net.URI base)` Generates the XBRLFact jdom node.
    `XMLElementDefinition` | `getElementDefinition()` Access to the element definition behind this fact.
    `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.
    `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)` Gets the friendly name.
    `java.util.Collection<HistoricalEventInterface>` | `getHistory()` Obtains a collection of all HistoricalEvent(s) produced .
    `java.lang.String` | `getHistoryAsString()` returns a text string with the fact history.
    `XBRLInstance` | `getInstance()` The instance document where this fact exists.
    `XBRLFactsList` | `getParent()` The parent of a fact is always a facts container.
    `XBRLTaxonomy` | `getTaxonomy()` The XBRLTaxonomy in which this fact is defined.
    `XBRLValidationReport` | `getValidationReport()` Access to the last stored validation report.
    `java.lang.String` | `getXPathToRoot()` Returns an XPath 2.0 expression to locate this document's node starting at this document's root This function updates the local namespace context if nodes in the path requires new namespaces to be declared.
    `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.
    `abstract boolean` | `isDuplicate(XBRLFact otherFact)` Check if two items are duplicates as defined in the XBRL 2.1 specification
    `boolean` | `isNil()` Return true if the fact is nil it MUST contain a @xsi:nil attribute with value = true.
    `boolean` | `isOnValidation()` When validation is a recursive process, this function returns true if the object going to be validated is already under validation.
    `boolean` | `pEqual(XBRLFact toFact)` Implementation of the p-equality as defined in the XBRL 2.1 specification.
    `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` | `setNil(boolean newValue)` Sets the nil attribute to true or false according to the param value.
    `void` | `setParent(XBRLFactsList parent)` Sets the parent of this XBRLFact to be the XBRLFactsList object used as a parameter.
    `void` | `setValue(net.sf.saxon.value.AtomicValue value)` Sets the value.
    `void` | `setValue(net.sf.saxon.s9api.XdmValue value)` Sets the value of this node.
    `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, addXMLChild, 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, getValue, getXPathExecutable, getXPathNamespaceContext, getXPathToNode, getXPointerElementScheme, getXPointerElementScheme, getXPointerShorthandScheme, getXPointerToNode, isDead, isNamespaceDefined, isXdmDocumentAttached, objEquals, objHashCode, qNameToString, removeAttribute, removeChild, removeChild, removeFromRelationship, removeToRelationship, removeXMLChild, resetElements, resetHash, resolve_equal2, resolveHRef, resolveHRef, s_equal2, s_equal2, s_equal2, setAttributes, setBase, setDocument, setDocumentAndReload, setElements, setLang, setNamespaceContext, setNamespaces, setNode, setNodeName, setParent, setRegenerateNodeIfnotFound, setVariablesDefined, size, thin, toString, valueEquals, xEqual`

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

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

- - ### Field Detail

    - #### nil

          public static final javax.xml.namespace.QName nil

      The Constant nil.

  - ### Method Detail

    - #### clone

          public XBRLFact clone()

      Overrides:
        `clone` in class `XMLFragment`

    - #### clone

          public XBRLFact clone(DTSContainer newDTS)

      Clone current fact but in a new DTSContainer.
      Overrides:
        `clone` in class `XMLFragment`
      Parameters:
        `newDTS` - the new dts
      Returns:
        cloned XBRLFact

    - #### setParent

          public void setParent(XBRLFactsList parent)

      Sets the parent of this XBRLFact to be the XBRLFactsList object used as a parameter.

      Setting the parent does not adds the fact as child of the parent element. This function do the following steps:

      1. if there are no changes (current parent is the same object as the object used as a parameter) then the function does nothing
      2. inform the old parent to remove the reference to the children
      3. sets parent of this object to be the object submitted as a parameter
      4. if the fact was assigned from a different instance document. Then relationships in the original instance document are removed from the new item.
      Parameters:
        `parent` - the new parent

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

    - #### getParent

          public XBRLFactsList getParent()

      The parent of a fact is always a facts container. The facts container can exist inside a tuple or inside an instance document.
      Specified by:
        `getParent` in interface `XMLHasParent`
      Overrides:
        `getParent` in class `XMLFragment`
      Returns:
        XBRLFactsList

    - #### getXPathToRoot

          public java.lang.String getXPathToRoot()

      Description copied from class: `XMLFragment`
      Returns an XPath 2.0 expression to locate this document's node starting at this document's root This function updates the local namespace context if nodes in the path requires new namespaces to be declared.
      Overrides:
        `getXPathToRoot` in class `XMLFragment`
      Returns:
        String

    - #### getElementDefinition

          public XMLElementDefinition getElementDefinition()

      Access to the element definition behind this fact.
      Returns:
        XMLElementDefinition

    - #### getInstance

          public XBRLInstance getInstance()

      The instance document where this fact exists.
      Returns:
        XBRLInstance

    - #### getTaxonomy

          public XBRLTaxonomy getTaxonomy()

      The XBRLTaxonomy in which this fact is defined.
      Returns:
        XBRLTaxonomy

    - #### pEqual

          public boolean pEqual(XBRLFact toFact)

      Implementation of the p-equality as defined in the XBRL 2.1 specification.

      p-equality means parent-equality. two facts are p-equal if they have the same parent node

      Parameters:
        `toFact` - the other fact to compare this fact to
      Returns:
        boolean value, true means this and toFact are p-equal

    - #### createItemOrTupleInstance

          public static XBRLFact createItemOrTupleInstance(DTSContainer dts,
                                           XBRLFactsList facts,
                                           net.sf.saxon.s9api.XdmNode node,
                                           int pos)
                                                    throws XBRLValidationException

      Creates a tupleInstance or a itemInstance depending on the node content.
      Parameters:
        `dts` - the dts
        `facts` - XBRLFactsContainer
        `node` - NodeInfo
        `pos` - the pos
      Returns:
        XBRLFact
      Throws:
        `XBRLValidationException` - the XBRL validation exception

    - #### createItemOrTupleInstance

          public static XBRLFact createItemOrTupleInstance(XBRLFactsList facts,
                                           XMLElementDefinition el,
                                           XBRLContext ctx,
                                           XBRLUnit unit)
                                                    throws XBRLInconsistentDTSException

      Creates a tupleInstance of a itemInstance depending on the data type of the el parameter and extra information provided in other parameters.
      Parameters:
        `facts` - XBRLFactsContainer if null, the fact will not be part of any factsList
        `el` - XBRLElementDefinition must be either XBRLTuple or XBRLItem, Cannot be null
        `ctx` - XBRLContext, if element is a tuple this parameter can be null
        `unit` - XBRLUnit, if element is not numeric or is a tuple this parameter can be null
      Returns:
        a new XBRLFact
      Throws:
        `XBRLInconsistentDTSException` - the XBRL inconsistent dts exception

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

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

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

    - #### generateLocatorToNode

          public XBRLLocator generateLocatorToNode(boolean relativize,
                                          java.net.URI base)
                                            throws java.net.URISyntaxException

      Generates a locator element pointing to the instantiated fact on the instance This is used during serialization of the instance document. The generation of a locator automatically adds an ID on the fact if needed
      Parameters:
        `relativize` - boolean
        `base` - URI base uri for relativization of the generated href
      Returns:
        XBRLLocator object
      Throws:
        `java.net.URISyntaxException` - the URI syntax exception

    - #### isNil

          public boolean isNil()

      Return true if the fact is nil it MUST contain a @xsi:nil attribute with value = true.
      Returns:
        boolean

    - #### isDuplicate

          public abstract boolean isDuplicate(XBRLFact otherFact)

      Check if two items are duplicates as defined in the XBRL 2.1 specification
      Parameters:
        `otherFact` - the other XBRLFactItem
      Returns:
        boolean

    - #### setNil

          public void setNil(boolean newValue)

      Sets the nil attribute to true or false according to the param value.
      Parameters:
        `newValue` - the new nil

    - #### setValue

          public void setValue(net.sf.saxon.value.AtomicValue value)

      Description copied from class: `XMLFragment`
      Sets the value.
      Overrides:
        `setValue` in class `XMLFragment`
      Parameters:
        `value` - the new value

    - #### setValue

          public void setValue(net.sf.saxon.s9api.XdmValue value)

      Description copied from class: `XMLFragment`
      Sets the value of this node.
      Overrides:
        `setValue` in class `XMLFragment`
      Parameters:
        `value` - the new value

    - #### generateNode

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

      Generates the XBRLFact jdom node. adds the xsi:nil attribute if required
      Overrides:
        `generateNode` in class `XMLFragment`
      Parameters:
        `relativize` - the relativize
        `base` - the base
      Returns:
        the element
      Throws:
        `XBRLSerializationException` - the XBRL serialization exception

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

      Gets the friendly name.
      Overrides:
        `getFriendlyName` in class `XMLFragment`
      Parameters:
        `modifiers` - the modifiers
        `lp` - the lp
      Returns:
        a String representation of this fact.

    - #### addEvent

          public void addEvent(java.lang.String message)

      Description copied from interface: `StoreHistoryInterface`
      Adds a new event at the time this method is called with the specified message.
      Specified by:
        `addEvent` in interface `StoreHistoryInterface`
      Parameters:
        `message` - the message

    - #### addEvent

          public void addEvent(java.util.Date date,
                      java.lang.String message)

      Description copied from interface: `StoreHistoryInterface`
      Adds a new event at the indicated date with the specificed message.
      Specified by:
        `addEvent` in interface `StoreHistoryInterface`
      Parameters:
        `date` - the date
        `message` - the message

    - #### addEvent

          public void addEvent(HistoricalEventInterface event)

      Description copied from interface: `StoreHistoryInterface`
      Adds a new event as an instance of an HistoricalEventInterface.
      Specified by:
        `addEvent` in interface `StoreHistoryInterface`
      Parameters:
        `event` - the event

    - #### getHistory

          public java.util.Collection<HistoricalEventInterface> getHistory()

      Description copied from interface: `ObtainHistoryInterface`
      Obtains a collection of all HistoricalEvent(s) produced .
      Specified by:
        `getHistory` in interface `ObtainHistoryInterface`
      Returns:
        collection of historical events

    - #### getHistoryAsString

          public java.lang.String getHistoryAsString()

      Description copied from interface: `ObtainHistoryInterface`
      returns a text string with the fact history.
      Specified by:
        `getHistoryAsString` in interface `ObtainHistoryInterface`
      Returns:
        history as string

    - #### clear

          public void clear()
                     throws java.lang.Throwable

      Eliminates all this fact content.
      Overrides:
        `clear` in class `XMLFragment`
      Throws:
        `java.lang.Throwable` - the throwable

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `XMLFragment`

    - #### equals

          public boolean equals(java.lang.Object obj)

      Description copied from class: `XMLFragment`
      Sets a new XPathFunctionResolver for this object.
      Overrides:
        `equals` in class `XMLFragment`
      Parameters:
        `obj` - the other
      Returns:
        true, if successful