com.ihr.xbrl.om.formula

## Class XBRLVariableResourceUse

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

-     public class XBRLVariableResourceUse
      extends java.lang.Object

  This is a class representing an XBRLVariableResource use. An USE of a variable resource has a name (the variable name as indicated in the relationship) and may have an evaluated value so this is a different object than the resource itself.

  A variable use can be shared between multiple variable sets. But it MUST not be shared between different threads evaluating the same variable name. Each thread must have its own local copy of the evaluation values.

  Author:
    Ignacio

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `XBRLVariableResourceUse(javax.xml.namespace.QName name, XBRLVariableFormulaEvaluable res, XBRLVariablesHolder set)` Instantiates a new XBRL variable resource use.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `checkOptimizer()` creates an optimizer of the XPath expressions and the implicit filters for all variables in the set.
    `boolean` | `checkVariable(java.util.Collection<net.sf.saxon.s9api.QName> resolved)` Execute validations as defined in the Formula specification.
    `int` | `evaluatedValueSize()` Access to the number of elements in the evaluation sequence.
    `net.sf.saxon.s9api.XdmValue` | `evaluateValue(XMLFragment evaluationContext, java.util.Collection<XBRLVariableResourceUse> evaluatedVars, boolean bResetAtEnd)` Evaluates this variable value.
    `XFValidationException` | `getEvaluationError()` Gets the evaluation error.
    `EvaluationType` | `getEvaluationType()` Computes the evaluation type for the value that
    `net.sf.saxon.s9api.XdmValue` | `getLastEvaluatedValue(XMLFragment evaluationContext, java.util.Collection<XBRLVariableResourceUse> availableVars)` Returns the last evaluated value for this variable from the cached value.
    `javax.xml.namespace.QName` | `getVariableName()` Access to the variable name (a QName).
    `XBRLVariableFormulaEvaluable` | `getVariableResource()` This is the XBRLVariableResource this variable use is assigned to.
    `net.sf.saxon.s9api.QName` | `getVariableS9APIQName()` Helper method to obtain the variable name using a saxon s9api QName rather than a java.xml.namespace.QName
    `java.util.Collection<javax.xml.namespace.QName>` | `getVariablesRequired()` Access to a collection of variable names required to evaluate this variable.
    `boolean` | `hasNext()` Returns true if this variable has been evaluated and there are more values not already obtained using calls to evaluateValue.
    `boolean` | `isEvaluated()` Returns true if this variable has been successfully evaluated the last time it was evaluated.
    `boolean` | `isFallbackDefined()` If the variable has a fall back value defined this method will return true. regardless the last evaluation is the fall back value or not.
    `boolean` | `isFallBackEvaluation()` Returns true if the last evaluated value is the fallback value.
    `boolean` | `isRecyclable()` Checks if is recyclable.
    `java.util.Vector<java.util.ArrayList<net.sf.saxon.s9api.XdmItem>>` | `preparePartitions(java.util.Vector<java.util.ArrayList<net.sf.saxon.s9api.XdmItem>> hsOutSeq, int uncoveredAspects)` For API use only.
    `void` | `recycle()` This method sets the internal iterator to the first element and avoids evaluating the XPath expression again.
    `void` | `replaceLastEvaluatedValue(net.sf.saxon.s9api.XdmValue newValue)` Sets the cache of the evaluated value to a specific value.
    `void` | `reset()` Sets this variable use to the status of not evaluated.
    `void` | `setIsEvaluated(boolean value)` Sets the cache of the evaluated flag value to a specific value.
    `void` | `setLastEvaluatedLen(int i)` Sets the cache of the evaluated sequence length to a specific value.
    `void` | `setVariableName(javax.xml.namespace.QName name)` Sets a specific variable name if needed.
    `long` | `size()` Size.

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

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

- - ### Constructor Detail

    - #### XBRLVariableResourceUse

          public XBRLVariableResourceUse(javax.xml.namespace.QName name,
                                 XBRLVariableFormulaEvaluable res,
                                 XBRLVariablesHolder set)

      Instantiates a new XBRL variable resource use.
      Parameters:
        `name` - the name
        `res` - the res
        `set` - the set

  - ### Method Detail

    - #### getVariableName

          public javax.xml.namespace.QName getVariableName()

      Access to the variable name (a QName).
      Returns:
        QName of the variable name.

    - #### setVariableName

          public void setVariableName(javax.xml.namespace.QName name)

      Sets a specific variable name if needed.
      Parameters:
        `name` - QName

    - #### getVariableResource

          public XBRLVariableFormulaEvaluable getVariableResource()

      This is the XBRLVariableResource this variable use is assigned to. The target object can be either a parameter, a general or a fact variable.
      Returns:
        instance of the XBRLVariableResource linked with this XBRLVariableResourceUse

    - #### getVariableS9APIQName

          public net.sf.saxon.s9api.QName getVariableS9APIQName()

      Helper method to obtain the variable name using a saxon s9api QName rather than a java.xml.namespace.QName
      Returns:
        net.sf.saxon.s9api.QName

    - #### evaluateValue

          public net.sf.saxon.s9api.XdmValue evaluateValue(XMLFragment evaluationContext,
                                                  java.util.Collection<XBRLVariableResourceUse> evaluatedVars,
                                                  boolean bResetAtEnd)
                                                    throws XFValidationException

      Evaluates this variable value.

      If the variable does not binds as sequence but the variable evaluation returns a sequence this method returns the first (or next) element in the sequence

      Parameters:
        `evaluationContext` - the evaluation context
        `evaluatedVars` - the evaluated vars
        `bResetAtEnd` - the b reset at end
      Returns:
        XdmValue
      Throws:
        `XFValidationException` - the XF validation exception

    - #### preparePartitions

          public java.util.Vector<java.util.ArrayList<net.sf.saxon.s9api.XdmItem>> preparePartitions(java.util.Vector<java.util.ArrayList<net.sf.saxon.s9api.XdmItem>> hsOutSeq,
                                                                                            int uncoveredAspects)
                                                                                              throws XFValidationException

      For API use only. It is public because Consistency assertions also use this method for preparation of the Assertion Data Set
      Parameters:
        `hsOutSeq` - the hs out seq
        `uncoveredAspects` - the uncovered aspects
      Returns:
        the vector
      Throws:
        `XFValidationException` - the XF validation exception

    - #### getLastEvaluatedValue

          public net.sf.saxon.s9api.XdmValue getLastEvaluatedValue(XMLFragment evaluationContext,
                                                          java.util.Collection<XBRLVariableResourceUse> availableVars)

      Returns the last evaluated value for this variable from the cached value. In case of evaluation errors, the method returns null and you can use `getEvaluationError()` to obtain the surrounding XFValidationException
      Parameters:
        `evaluationContext` - the evaluation context
        `availableVars` - the available vars
      Returns:
        XdmValue

    - #### getEvaluationError

          public XFValidationException getEvaluationError()

      Gets the evaluation error.
      Returns:
        the errorDuringEvaluation

    - #### evaluatedValueSize

          public int evaluatedValueSize()

      Access to the number of elements in the evaluation sequence.
      Returns:
        integer

    - #### getVariablesRequired

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

      Access to a collection of variable names required to evaluate this variable.

      This is static information once the variable and all its filters are compiled.

      Returns:
        Collection of QName

    - #### checkVariable

          public boolean checkVariable(java.util.Collection<net.sf.saxon.s9api.QName> resolved)
                                throws XFValidationException

      Execute validations as defined in the Formula specification. This method is used internally by the API.
      Parameters:
        `resolved` - the resolved
      Returns:
        true, if successful
      Throws:
        `XFValidationException` - the XF validation exception

    - #### checkOptimizer

          public void checkOptimizer()

      creates an optimizer of the XPath expressions and the implicit filters for all variables in the set.

    - #### replaceLastEvaluatedValue

          public void replaceLastEvaluatedValue(net.sf.saxon.s9api.XdmValue newValue)

      Sets the cache of the evaluated value to a specific value. This method is used internally by the API.
      Parameters:
        `newValue` - the new value

    - #### isEvaluated

          public boolean isEvaluated()

      Returns true if this variable has been successfully evaluated the last time it was evaluated.
      Returns:
        boolean value

    - #### getEvaluationType

          public EvaluationType getEvaluationType()

      Computes the evaluation type for the value that
      Returns:
        EvaluationType

    - #### setLastEvaluatedLen

          public void setLastEvaluatedLen(int i)

      Sets the cache of the evaluated sequence length to a specific value. This method is used internally by the API.
      Parameters:
        `i` - the new last evaluated len

    - #### setIsEvaluated

          public void setIsEvaluated(boolean value)

      Sets the cache of the evaluated flag value to a specific value. This method is used internally by the API.
      Parameters:
        `value` - the new checks if is evaluated

    - #### reset

          public void reset()

      Sets this variable use to the status of not evaluated. This will cause the next time evaluateValue will be called the expression will be evaluated again

    - #### hasNext

          public boolean hasNext()

      Returns true if this variable has been evaluated and there are more values not already obtained using calls to evaluateValue.
      Returns:
        true, if successful

    - #### isFallbackDefined

          public boolean isFallbackDefined()

      If the variable has a fall back value defined this method will return true. regardless the last evaluation is the fall back value or not. If the variable has no fall back value defined this method returns false
      Returns:
        true, if is fallback defined

    - #### isFallBackEvaluation

          public boolean isFallBackEvaluation()

      Returns true if the last evaluated value is the fallback value.
      Returns:
        boolean

    - #### size

          public long size()

      Size.
      Returns:
        the long

    - #### recycle

          public void recycle()

      This method sets the internal iterator to the first element and avoids evaluating the XPath expression again.

    - #### isRecyclable

          public boolean isRecyclable()

      Checks if is recyclable.
      Returns:
        true, if is recyclable