com.ihr.xbrl.om.formula

## Class XBRLVariableInternal

- java.lang.Object
- - com.ihr.xbrl.om.formula.XBRLVariableInternal

- All Implemented Interfaces:
    XBRLVariableFormulaEvaluable

      public class XBRLVariableInternal
      extends java.lang.Object
      implements XBRLVariableFormulaEvaluable

  This allows for creating a XBRLVariableResourceUse derived from something the extension of the formula processor can use.

  This class implements the XBRLVariableFormulaEvaluable interface

  Author:
    Ignacio

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `XBRLVariableInternal(XBRLFormulaProcessor proc, net.sf.saxon.s9api.XdmValue value)` Instantiates a new XBRL variable internal.
    `XBRLVariableInternal(XBRLFormulaProcessor proc, net.sf.saxon.s9api.XdmValue value, boolean bindAsSequence)` Instantiates a new XBRL variable internal.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `net.sf.saxon.s9api.XdmValue` | `adjustValueAccordingToType(net.sf.saxon.s9api.XdmValue val, net.sf.saxon.s9api.XdmItem item)` Checks if the variable has a "as" attribute and: * if it exist; the value in the item parameter is converted to the type indicated * if it does not exist; the value of the val parameter is returned.
    `boolean` | `bindAsSequence()` In the case of resource based variables this reads the surrounding syntax and returns the value of the bindAsSequence.
    `boolean` | `checkVariable(XBRLVariablesHolder set, javax.xml.namespace.QName name, java.util.Collection<net.sf.saxon.s9api.QName> resolved)` Called for variables that are also resources during the static compilation phase of the formula preparation.
    `void` | `clear()` Used to clean up evaluation caches.
    `Evaluation` | `evaluateValue(XMLFragment evaluationContext, java.util.Collection<XBRLVariableResourceUse> availableVars, XBRLVariableSetResource set)` Evaluates the resource internal XPath expression and returns either the returned value from the XPath expression or the fall back value in the case of variables that may have a fall back value and the rawEvaluation of the XPath expression results in the empty sequence.
    `java.util.List<XBRLFilterUse>` | `getFilters(int aspect)` Gets the filters.
    `XBRLFormulaProcessor` | `getProcessor()` Returns an instance of the XBRLFormulaProcessor this variable has been created under
    `java.util.Collection<javax.xml.namespace.QName>` | `getVariablesRequired(XBRLVariablesHolder set)` Returns a collection of variables required for the evaluation of this variable.
    `XBRLVariableType` | `getVariableType()` Gets the variable type.
    `XMLFragment` | `getXMLFragment()` Returns the surrounding XML Fragment this resource comes from.
    `boolean` | `hasFilterAspect(int aspect, javax.xml.namespace.QName dimName)` Checks for filter aspect.
    `Evaluation` | `rawEvaluateValue(XMLFragment evaluationContext, java.util.Collection<XBRLVariableResourceUse> availableVars)` Evaluates the resource internal XPath expression and returns the sequence.

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

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### XBRLVariableInternal

          public XBRLVariableInternal(XBRLFormulaProcessor proc,
                              net.sf.saxon.s9api.XdmValue value)

      Instantiates a new XBRL variable internal.
      Parameters:
        `proc` - the proc
        `value` - the value

    - #### XBRLVariableInternal

          public XBRLVariableInternal(XBRLFormulaProcessor proc,
                              net.sf.saxon.s9api.XdmValue value,
                              boolean bindAsSequence)

      Instantiates a new XBRL variable internal.
      Parameters:
        `proc` - the proc
        `value` - the value
        `bindAsSequence` - the bind as sequence

  - ### Method Detail

    - #### evaluateValue

          public Evaluation evaluateValue(XMLFragment evaluationContext,
                                 java.util.Collection<XBRLVariableResourceUse> availableVars,
                                 XBRLVariableSetResource set)
                                   throws XFValidationException

      Description copied from interface: `XBRLVariableFormulaEvaluable`
      Evaluates the resource internal XPath expression and returns either the returned value from the XPath expression or the fall back value in the case of variables that may have a fall back value and the rawEvaluation of the XPath expression results in the empty sequence. The raw evaluation of the XPath expression is implemented in the rawEvaluateValue(XMLFragment, Collection) call.
      Specified by:
        `evaluateValue` in interface `XBRLVariableFormulaEvaluable`
      Parameters:
        `evaluationContext` - the evaluation context
        `availableVars` - the available vars
        `set` - the set
      Returns:
        the evaluation
      Throws:
        `XFValidationException` - the XF validation exception
      See Also:
        `XBRLVariableFormulaEvaluable.rawEvaluateValue(XMLFragment, Collection)`

    - #### rawEvaluateValue

          public Evaluation rawEvaluateValue(XMLFragment evaluationContext,
                                    java.util.Collection<XBRLVariableResourceUse> availableVars)
                                      throws XFValidationException

      Description copied from interface: `XBRLVariableFormulaEvaluable`
      Evaluates the resource internal XPath expression and returns the sequence. This method does not considers nor evaluates the default value if any is possible. The evaluation considering default values is implemented in the `XBRLVariableFormulaEvaluable.evaluateValue(XMLFragment, Collection, XBRLVariableSetResource)` method.
      Specified by:
        `rawEvaluateValue` in interface `XBRLVariableFormulaEvaluable`
      Parameters:
        `evaluationContext` - the evaluation context
        `availableVars` - the available vars
      Returns:
        the evaluation
      Throws:
        `XFValidationException` - the XF validation exception

    - #### clear

          public void clear()

      Description copied from interface: `XBRLVariableFormulaEvaluable`
      Used to clean up evaluation caches.
      Specified by:
        `clear` in interface `XBRLVariableFormulaEvaluable`

    - #### bindAsSequence

          public boolean bindAsSequence()

      Description copied from interface: `XBRLVariableFormulaEvaluable`
      In the case of resource based variables this reads the surrounding syntax and returns the value of the bindAsSequence.

      In other cases relays on the implementation

      Specified by:
        `bindAsSequence` in interface `XBRLVariableFormulaEvaluable`
      Returns:
        true, if successful

    - #### checkVariable

          public boolean checkVariable(XBRLVariablesHolder set,
                              javax.xml.namespace.QName name,
                              java.util.Collection<net.sf.saxon.s9api.QName> resolved)
                                throws XFValidationException

      Description copied from interface: `XBRLVariableFormulaEvaluable`
      Called for variables that are also resources during the static compilation phase of the formula preparation.

      throws exceptions according to the validation rules.

      shall return true on success

      Specified by:
        `checkVariable` in interface `XBRLVariableFormulaEvaluable`
      Parameters:
        `set` - the set
        `name` - the name
        `resolved` - the resolved
      Returns:
        true, if successful
      Throws:
        `XFValidationException` - the XF validation exception

    - #### getVariablesRequired

          public java.util.Collection<javax.xml.namespace.QName> getVariablesRequired(XBRLVariablesHolder set)

      Description copied from interface: `XBRLVariableFormulaEvaluable`
      Returns a collection of variables required for the evaluation of this variable.
      Specified by:
        `getVariablesRequired` in interface `XBRLVariableFormulaEvaluable`
      Parameters:
        `set` - the set
      Returns:
        collection of QNames

    - #### getProcessor

          public XBRLFormulaProcessor getProcessor()

      Description copied from interface: `XBRLVariableFormulaEvaluable`
      Returns an instance of the XBRLFormulaProcessor this variable has been created under
      Specified by:
        `getProcessor` in interface `XBRLVariableFormulaEvaluable`
      Returns:
        XBRLFormulaProcessor

    - #### getFilters

          public java.util.List<XBRLFilterUse> getFilters(int aspect)

      Description copied from interface: `XBRLVariableFormulaEvaluable`
      Gets the filters.
      Specified by:
        `getFilters` in interface `XBRLVariableFormulaEvaluable`
      Parameters:
        `aspect` - the aspect
      Returns:
        the filters

    - #### hasFilterAspect

          public boolean hasFilterAspect(int aspect,
                                javax.xml.namespace.QName dimName)

      Description copied from interface: `XBRLVariableFormulaEvaluable`
      Checks for filter aspect.
      Specified by:
        `hasFilterAspect` in interface `XBRLVariableFormulaEvaluable`
      Parameters:
        `aspect` - the aspect
        `dimName` - if aspect is DIMENSION then dimName is the dimension name
      Returns:
        true, if successful

    - #### getVariableType

          public XBRLVariableType getVariableType()

      Description copied from interface: `XBRLVariableFormulaEvaluable`
      Gets the variable type.
      Specified by:
        `getVariableType` in interface `XBRLVariableFormulaEvaluable`
      Returns:
        the variable type

    - #### adjustValueAccordingToType

          public net.sf.saxon.s9api.XdmValue adjustValueAccordingToType(net.sf.saxon.s9api.XdmValue val,
                                                               net.sf.saxon.s9api.XdmItem item)
                                                                 throws XFValidationException

      Description copied from interface: `XBRLVariableFormulaEvaluable`
      Checks if the variable has a "as" attribute and: * if it exist; the value in the item parameter is converted to the type indicated * if it does not exist; the value of the val parameter is returned.
      Specified by:
        `adjustValueAccordingToType` in interface `XBRLVariableFormulaEvaluable`
      Parameters:
        `val` - value to be returned when no "as" attribute exist on variable
        `item` - the value that must be converted to the type indicated in the as attribute
      Returns:
        XdmValue (atomic) or the value of the val parameter
      Throws:
        `XFValidationException` - the XF validation exception

    - #### getXMLFragment

          public XMLFragment getXMLFragment()

      Description copied from interface: `XBRLVariableFormulaEvaluable`
      Returns the surrounding XML Fragment this resource comes from.
      Specified by:
        `getXMLFragment` in interface `XBRLVariableFormulaEvaluable`
      Returns:
        the XML fragment