com.ihr.xbrl.om.xdt

## Class XDTFact

- java.lang.Object
- - com.ihr.xbrl.om.xdt.XDTFact

- Direct Known Subclasses:
    XDTFactForApplications

      public class XDTFact
      extends java.lang.Object

  This is a fact in the instance document that can be validated against the XDT specification.
  Author:
    Ignacio

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `XDTFact(javax.xml.namespace.QName primaryItemQName, XDTProcessor processor, java.util.Hashtable<javax.xml.namespace.QName,XMLFragment> segmentDimData, java.util.Hashtable<javax.xml.namespace.QName,XMLFragment> scenarioDimData)` Creates a new XDTFact object without a backup primary item.
    `XDTFact(XBRLFactItem fact, XDTProcessor processor, boolean bThrowValidationExceptions)` Creates a new XDTFact object, this is, the representation of a fact with its dimensions according to the XDT Specification 1.0

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `equals(java.lang.Object obj)`
    `int` | `getDimensionPreferredContainer(javax.xml.namespace.QName dimension)` Gets the dimension preferred container.
    `java.lang.Object` | `getDimensionValue(int container, javax.xml.namespace.QName dimension)` Obtains the value for a dimension on this fact level.
    `java.lang.Object` | `getDimensionValue(javax.xml.namespace.QName dimension)` Gets the dimension value.
    `XBRLFactItem` | `getFact()` Gets the fact.
    `XDTProcessor` | `getProcessor()` Gets the processor.
    `int` | `hashCode()`
    `boolean` | `isDefaultValue(javax.xml.namespace.QName dimension)` Returns a boolean value indicating whether for this fact the dimension value is the dimension default or not.
    `boolean` | `validate(java.lang.StringBuffer reasonError, XDTValidationFactHistory valTrack)` Validate.

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

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

- - ### Constructor Detail

    - #### XDTFact

          public XDTFact(XBRLFactItem fact,
                 XDTProcessor processor,
                 boolean bThrowValidationExceptions)

      Creates a new XDTFact object, this is, the representation of a fact with its dimensions according to the XDT Specification 1.0
      Parameters:
        `fact` - the surrounding fact item. null is allowed here. (if required for GUIs)
        `processor` - the instance of the XDTProcessor to use (just in case fact is null)
        `bThrowValidationExceptions` - if this parameter is true, the process of getting the dimensions from the context (during the object creation process) may raise XDTValidation exceptions. If this parameter is false an exception will not be raised (even if the context is not valid)

    - #### XDTFact

          public XDTFact(javax.xml.namespace.QName primaryItemQName,
                 XDTProcessor processor,
                 java.util.Hashtable<javax.xml.namespace.QName,XMLFragment> segmentDimData,
                 java.util.Hashtable<javax.xml.namespace.QName,XMLFragment> scenarioDimData)

      Creates a new XDTFact object without a backup primary item. This can be used to validate the fact before the fact item is created
      Parameters:
        `primaryItemQName` - the primary item q name
        `processor` - the instance of the XDTProcessor to use (just in case fact is null)
        `segmentDimData` - the segment dim data
        `scenarioDimData` - the scenario dim data

  - ### Method Detail

    - #### getFact

          public XBRLFactItem getFact()

      Gets the fact.
      Returns:
        the fact

    - #### getProcessor

          public XDTProcessor getProcessor()

      Gets the processor.
      Returns:
        the processor

    - #### getDimensionValue

          public java.lang.Object getDimensionValue(int container,
                                           javax.xml.namespace.QName dimension)

      Obtains the value for a dimension on this fact level.

      This value is not for validation purposes, but for application consumption.

      If container is -1 only the default value is returned.

      If container is either XDTHypercubeUse.SEGMENT or XDTHypercubeUse.SCENARIO the value returned is the explicitly value set or the default value if there is none and the dimension has a default.

      For this function it is not an error to have the same dimension in both containers (with the same or different values) as that was the interpretation of the specification before errata corrections on 2009/09/07. Now there are two other functions (NOT RECOMMENDED) `getDimensionValue(QName)` and `getDimensionPreferredContainer(QName)` that considers that one dimension can only exist in one dimension container (according to the new interpretation of the XDT spec that is inconsistent with the XBRL 2.1 spec).

      Parameters:
        `container` - integer constant `XDTHypercubeUse.SEGMENT` or `XDTHypercubeUse.SCENARIO`
        `dimension` - the dimension QName
      Returns:
        Object, if the dimension is explicit, the function returns the QName value. if the dimension is typed the function returns the XML node

    - #### isDefaultValue

          public boolean isDefaultValue(javax.xml.namespace.QName dimension)

      Returns a boolean value indicating whether for this fact the dimension value is the dimension default or not.

      Note this function is never used during XDT validation as the algorithm for validation does not requires this information. This is just a helper function for applications.

      If the dimension does not exists in the DTS this function returns "true".

      If the dimension does not define a default this function returns "false".

      For typed dimensions this function returns "false".

      Parameters:
        `dimension` - the dimension QName
      Returns:
        boolean true if the dimension is explicit and there is a default value defined for the dimension and there is nothing in the context so the default value applies
      Since:
        2.7.4

    - #### getDimensionValue

          public java.lang.Object getDimensionValue(javax.xml.namespace.QName dimension)

      Gets the dimension value.
      Parameters:
        `dimension` - the dimension
      Returns:
        the dimension value
      See Also:
        `getDimensionValue(int, QName)`

    - #### getDimensionPreferredContainer

          public int getDimensionPreferredContainer(javax.xml.namespace.QName dimension)

      Gets the dimension preferred container.
      Parameters:
        `dimension` - the dimension
      Returns:
        the dimension preferred container
      See Also:
        `{@link XDTHypercubeUse#SEGMENT} or {@link XDTHypercubeUse#SCENARIO} or {@link XDTHypercubeUse#UNDEFINED}`

    - #### validate

          public boolean validate(java.lang.StringBuffer reasonError,
                         XDTValidationFactHistory valTrack)

      Validate.
      Parameters:
        `reasonError` - if the result is invalid, this string buffer contains human readable explanation about the reason
        `valTrack` - stores information about the validation process of this fact in order to produce a message at the end of the process
      Returns:
        boolean true if valid, false if not valid

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `java.lang.Object`

    - #### equals

          public boolean equals(java.lang.Object obj)

      Overrides:
        `equals` in class `java.lang.Object`