com.ihr.xbrl.om.formula

## Class XBRLVariableSetResource

- java.lang.Object
- - com.ihr.xbrl.om.XMLFragment
  - - com.ihr.xbrl.om.exLinks.XLinkElement
    - - com.ihr.xbrl.om.exLinks.XBRLPointerOfARelationship
      - - com.ihr.xbrl.om.exLinks.XBRLResource
        - - com.ihr.xbrl.om.formula.XBRLFormulaResource
          - - com.ihr.xbrl.om.formula.XBRLVariableSetResource

- All Implemented Interfaces:
    HasAdditionalEqualityForReassignation, XBRLRelationshipPoint, HasFormulaProcessor, HasUncoveredAspectValueResolver, XBRLVariablesHolder, Thinable, XBRLValidation, XBRLValueKey, XMLHasParent, java.lang.Cloneable, javax.xml.namespace.NamespaceContext
  Direct Known Subclasses:
    XBRLAssertion, XBRLFormula

      public abstract class XBRLVariableSetResource
      extends XBRLFormulaResource
      implements XBRLVariablesHolder, HasUncoveredAspectValueResolver

  The Class XBRLVariableSetResource.
  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` | `aspectModel` The Constant aspectModel.
    `static javax.xml.namespace.QName` | `implicitFiltering` The Constant implicitFiltering.
    `static org.apache.log4j.Logger` | `log` The log.

    - ### Fields inherited from class com.ihr.xbrl.om.exLinks.XBRLResource

      `nullResource`

    - ### Fields inherited from class com.ihr.xbrl.om.exLinks.XLinkElement

      `actuate, ACTUATE, ARC, arcrole, ARCROLE, ETITLE, EXTENDED, from, FROM, href, HREF, label, LABEL, LOCATOR, RESOURCE, role, ROLE, show, SHOW, SIMPLE, title, TITLE, to, TO, TYPE`

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

    - ### Fields inherited from interface com.ihr.xbrl.om.formula.XBRLVariablesHolder

      `MODEL_DIMENSIONAL, MODEL_NON_DIMENSIONAL`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `XBRLVariableSetResource(XBRLFormulaProcessor proc, XBRLExtendedLink parent, net.sf.saxon.s9api.XdmNode resNode)` Instantiates a new XBRL variable set resource.
    `XBRLVariableSetResource(XBRLFormulaProcessor proc, XBRLResource other)` Instantiates a new XBRL variable set resource.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static java.util.Collection<? extends javax.xml.namespace.QName>` | `allDimensions(XBRLFact xFact)` All dimensions.
    `boolean` | `bindCycle(XPathHelper xph)` Bind cycle.
    `TraceVariablesBind` | `bindLastEvaluatedVariableValues(net.sf.saxon.s9api.XPathSelector xpathExpression, java.util.Collection<javax.xml.namespace.QName> requiredVariables)` This method should be called when there is no need to advance to the next values in the sequence.
    `void` | `bindParameters(net.sf.saxon.s9api.XPathSelector xpathExpression, java.util.Collection<javax.xml.namespace.QName> requiredVariables)` Bind parameters.
    `void` | `bindVariableValue(net.sf.saxon.s9api.QName varName, net.sf.saxon.s9api.XPathSelector sel)` Bind variable value.
    `void` | `checkCyclicDependencies(javax.xml.namespace.QName source)` Starting variable to check cycles from.
    `void` | `compileFilters()` Compile filters.
    `net.sf.saxon.s9api.XPathExecutable` | `compileFormulaExpression(java.lang.String expression, boolean namespaces, boolean variables)` Compile formula expression.
    `java.util.Collection<javax.xml.namespace.QName>` | `declareVariables(net.sf.saxon.s9api.XPathCompiler compiler, boolean bNamespaces, boolean bVariables, javax.xml.namespace.QName name)` Declare variables.
    `int` | `getAspectModel()` Returns either XBRLVariablesHolder.MODEL_DIMENSIONAL or XBRLVariablesHolder.MODEL_NON_DIMENSIONAL
    `java.util.Collection<net.sf.saxon.s9api.QName>` | `getBindableVariableNames()` Access to a collection of QNames (Saxon s9api QNames) of all variables that are defined in this XBRLVariablesHolder
    `java.util.Collection<XBRLFilterUse>` | `getFilters()` Returns a collection of XBRLFilterUse instance representing the use of filters associated to this XBRLVariablesHolder.
    `int` | `getNumberOfVariables()` Gets the number of variables.
    `XFIImplicitFilterOptimizer` | `getOptimizer()` Returns the optimizer for the set. this may be null
    `static int` | `getUncoveredAspectsSet(java.util.Collection<XBRLVariableResourceUse> variableUses, XBRLVariablesHolder set)` Computes uncovered aspects in common in all variables in the set.
    `net.sf.saxon.s9api.XdmValue` | `getUncoveredAspectValue(int aspect, javax.xml.namespace.QName dimName)` Used only for the implementation of the xff.uncovered-aspect(aspect, dimName) XPath function
    `XBRLVariableFormulaEvaluable` | `getVariableResource(javax.xml.namespace.QName variableName)` Access to the variable resource by its variable name.
    `java.util.Collection<XBRLVariableResourceUse>` | `getVariableResourceUses()` Access to variables linked with this variable set.
    `XBRLVariableResourceUse` | `getVariableUse(javax.xml.namespace.QName variableName)` Obtains the instance of the XBRLVariableResourceUse on this variable set using the variable name.
    `net.sf.saxon.s9api.XdmValue` | `getVariableValue(javax.xml.namespace.QName variableName)` Access to the variable value using the variable name.
    `net.sf.saxon.s9api.XdmValue` | `getVariableValue(javax.xml.namespace.QName variableName, int aspect, javax.xml.namespace.QName dimName)` Access to the variable value using the variable name.
    `XFIImplicitFilterOptimizer` | `getXFIImplicitFilterOptimizer()` Returns or creates the instance of the fact variable optimizer when the fact variable is used with implicit filtering in a set with more than 2 variables.
    `boolean` | `isCovered(javax.xml.namespace.QName source, int aspect)` Returns true when the variable used in the source parameter is covered.
    `boolean` | `isImplicitFilter()` Returns the value of the implicitfiltering attribute for this variableSet.

    - ### Methods inherited from class com.ihr.xbrl.om.formula.XBRLFormulaResource

      `getProcessor`

    - ### Methods inherited from class com.ihr.xbrl.om.exLinks.XBRLResource

      `addChild, clear, equals, generateLocatorToNode, generateNode, getAttributes, getDTSBase, getFriendlyName, getFriendlyName, getParent, getResourceIdentifier, getRoleType, getType, getValidationReport, getValueKey, hashCode, invalidate, invalidate, isComplexType, isOnValidation, isSimpleType, setComplexType, setDTSBase, setId, setParent, setRole, setRoleType, setSimpleType, setValue, validate`

    - ### Methods inherited from class com.ihr.xbrl.om.exLinks.XLinkElement

      `getActuate, getArcrole, getFromTxt, getHRef, getLabel, getRole, getShow, getStaticLabel, getSType, getTitle, getToTxt, isRequiredAttribute, isValidAttribute, setActuate, setArcrole, setFrom, setHRef, setLabel, setShow, setSType, setTitle, setTo`

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

      `addAttribute, addFromRelationship, addNamespace, addNamespace, addToRelationship, addXMLChild, changeBase, checkBase, clone, clone, delAttribute, delAttribute, equalXdmValues, evaluateBoolean, evaluateList, evaluateNode, evaluateNumber, evaluateString, generateId, generateNodeNamespacesAndAttributes, generateNodeValue, generatePrefix, getAllAttributes, getAttribute, getAttributeBooleanValue, getAttributeQNameValue, getAttributes, getAttributeStringValue, getAttributeValue, getBase, getBase, getBaseURI, getBooleanValue, getChild, getContainer, getContainerDocumentURI, getDeclaredNamespaces, getDocument, getElements, 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, getXPathToRoot, 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, setValue, setVariablesDefined, size, thin, toString, valueEquals, xEqual`

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

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

    - ### Methods inherited from interface com.ihr.xbrl.om.formula.HasFormulaProcessor

      `getProcessor`

    - ### Methods inherited from interface com.ihr.xbrl.om.exLinks.XBRLRelationshipPoint

      `addFromRelationship, addToRelationship, getFromRelationships, getToRelationships, removeFromRelationship, removeToRelationship`

- - ### Field Detail

    - #### log

          public static org.apache.log4j.Logger log

      The log.

    - #### implicitFiltering

          public static final javax.xml.namespace.QName implicitFiltering

      The Constant implicitFiltering.

    - #### aspectModel

          public static final javax.xml.namespace.QName aspectModel

      The Constant aspectModel.

  - ### Constructor Detail

    - #### XBRLVariableSetResource

          public XBRLVariableSetResource(XBRLFormulaProcessor proc,
                                 XBRLExtendedLink parent,
                                 net.sf.saxon.s9api.XdmNode resNode)
                                  throws XFValidationException

      Instantiates a new XBRL variable set resource.
      Parameters:
        `proc` - the proc
        `parent` - the parent
        `resNode` - the res node
      Throws:
        `XFValidationException` - the XF validation exception

    - #### XBRLVariableSetResource

          public XBRLVariableSetResource(XBRLFormulaProcessor proc,
                                 XBRLResource other)
                                  throws XFValidationException

      Instantiates a new XBRL variable set resource.
      Parameters:
        `proc` - the proc
        `other` - the other
      Throws:
        `XFValidationException` - the XF validation exception

  - ### Method Detail

    - #### getAspectModel

          public int getAspectModel()

      Description copied from interface: `XBRLVariablesHolder`
      Returns either XBRLVariablesHolder.MODEL_DIMENSIONAL or XBRLVariablesHolder.MODEL_NON_DIMENSIONAL
      Specified by:
        `getAspectModel` in interface `XBRLVariablesHolder`
      Returns:
        one of the two constants

    - #### isImplicitFilter

          public boolean isImplicitFilter()

      Returns the value of the implicitfiltering attribute for this variableSet.
      Specified by:
        `isImplicitFilter` in interface `HasUncoveredAspectValueResolver`
      Specified by:
        `isImplicitFilter` in interface `XBRLVariablesHolder`
      Returns:
        boolean

    - #### bindCycle

          public boolean bindCycle(XPathHelper xph)
                            throws XFValidationException

      Bind cycle.
      Parameters:
        `xph` - the xph
      Returns:
        true, if successful
      Throws:
        `XFValidationException` - the XF validation exception

    - #### getVariableResourceUses

          public java.util.Collection<XBRLVariableResourceUse> getVariableResourceUses()

      Access to variables linked with this variable set.
      Returns:
        Collection of XBRLVariableResourceUse

    - #### allDimensions

          public static java.util.Collection<? extends javax.xml.namespace.QName> allDimensions(XBRLFact xFact)

      All dimensions.
      Parameters:
        `xFact` - the x fact
      Returns:
        the collection

    - #### bindLastEvaluatedVariableValues

          public TraceVariablesBind bindLastEvaluatedVariableValues(net.sf.saxon.s9api.XPathSelector xpathExpression,
                                                           java.util.Collection<javax.xml.namespace.QName> requiredVariables)

      This method should be called when there is no need to advance to the next values in the sequence.
      Parameters:
        `xpathExpression` - the xpath expression
        `requiredVariables` - the required variables
      Returns:
        the trace variables bind

    - #### bindParameters

          public void bindParameters(net.sf.saxon.s9api.XPathSelector xpathExpression,
                            java.util.Collection<javax.xml.namespace.QName> requiredVariables)

      Bind parameters.
      Parameters:
        `xpathExpression` - the xpath expression
        `requiredVariables` - the required variables

    - #### declareVariables

          public java.util.Collection<javax.xml.namespace.QName> declareVariables(net.sf.saxon.s9api.XPathCompiler compiler,
                                                                         boolean bNamespaces,
                                                                         boolean bVariables,
                                                                         javax.xml.namespace.QName name)
                                                                           throws XFValidationException

      Declare variables.
      Parameters:
        `compiler` - the compiler
        `bNamespaces` - the b namespaces
        `bVariables` - the b variables
        `name` - the name
      Returns:
        the collection
      Throws:
        `XFValidationException` - the XF validation exception

    - #### checkCyclicDependencies

          public void checkCyclicDependencies(javax.xml.namespace.QName source)
                                       throws XFValidationException

      Starting variable to check cycles from.
      Parameters:
        `source` - QName
      Throws:
        `XFValidationException` - the XF validation exception

    - #### getVariableUse

          public XBRLVariableResourceUse getVariableUse(javax.xml.namespace.QName variableName)

      Obtains the instance of the XBRLVariableResourceUse on this variable set using the variable name.

      The constructor of the XBRLVariableSetResource already calls readVariables so it is almost impossible this method raises XFRuntimeException

      Parameters:
        `variableName` - the variable name
      Returns:
        instance of XBRLVariableResourceUse or null if none exist

    - #### getVariableResource

          public XBRLVariableFormulaEvaluable getVariableResource(javax.xml.namespace.QName variableName)

      Description copied from interface: `XBRLVariablesHolder`
      Access to the variable resource by its variable name.
      Specified by:
        `getVariableResource` in interface `XBRLVariablesHolder`
      Parameters:
        `variableName` - the q var
      Returns:
        XBRLVariableResource

    - #### getVariableValue

          public net.sf.saxon.s9api.XdmValue getVariableValue(javax.xml.namespace.QName variableName)
                                                       throws XFValidationException

      Description copied from interface: `XBRLVariablesHolder`
      Access to the variable value using the variable name. The returned value corresponds to the last evaluated value and is not evaluated again. It was evaluated prior to the formula expression evaluation
      Specified by:
        `getVariableValue` in interface `XBRLVariablesHolder`
      Parameters:
        `variableName` - javax.xml.namespace.QName
      Returns:
        XdmValue
      Throws:
        `XFValidationException` - the XF validation exception

    - #### getVariableValue

          public net.sf.saxon.s9api.XdmValue getVariableValue(javax.xml.namespace.QName variableName,
                                                     int aspect,
                                                     javax.xml.namespace.QName dimName)
                                                       throws XFValidationException

      Access to the variable value using the variable name. The returned value corresponds to the last evaluated value and is not evaluated again. It was evaluated prior to the formula expression evaluation.

      This function is able to deal with the formula:uncovered variable name and obtains the SAV according to the specification.

      Parameters:
        `variableName` - the variable name
        `aspect` - the aspect
        `dimName` - Optional, dimension name. Used only when aspect is DIMENSION
      Returns:
        XdmValue
      Throws:
        `XFValidationException` - the XF validation exception

    - #### getUncoveredAspectValue

          public net.sf.saxon.s9api.XdmValue getUncoveredAspectValue(int aspect,
                                                            javax.xml.namespace.QName dimName)
                                                              throws XFValidationException

      Description copied from interface: `HasUncoveredAspectValueResolver`
      Used only for the implementation of the xff.uncovered-aspect(aspect, dimName) XPath function
      Specified by:
        `getUncoveredAspectValue` in interface `HasUncoveredAspectValueResolver`
      Parameters:
        `aspect` - the aspect
        `dimName` - the dim name
      Returns:
        the uncovered aspect value
      Throws:
        `XFValidationException` - the XF validation exception

    - #### compileFilters

          public void compileFilters()
                              throws XFValidationException

      Compile filters.
      Throws:
        `XFValidationException` - the XF validation exception

    - #### getFilters

          public java.util.Collection<XBRLFilterUse> getFilters()

      Description copied from interface: `XBRLVariablesHolder`
      Returns a collection of XBRLFilterUse instance representing the use of filters associated to this XBRLVariablesHolder. Used while checking variables in order to obtain global filters
      Specified by:
        `getFilters` in interface `XBRLVariablesHolder`
      Returns:
        the filters

    - #### compileFormulaExpression

          public net.sf.saxon.s9api.XPathExecutable compileFormulaExpression(java.lang.String expression,
                                                                    boolean namespaces,
                                                                    boolean variables)
                                                                      throws XFValidationException

      Compile formula expression.
      Parameters:
        `expression` - the expression
        `namespaces` - the namespaces
        `variables` - the variables
      Returns:
        the x path executable
      Throws:
        `XFValidationException` - the XF validation exception

    - #### getBindableVariableNames

          public java.util.Collection<net.sf.saxon.s9api.QName> getBindableVariableNames()

      Description copied from interface: `XBRLVariablesHolder`
      Access to a collection of QNames (Saxon s9api QNames) of all variables that are defined in this XBRLVariablesHolder
      Specified by:
        `getBindableVariableNames` in interface `XBRLVariablesHolder`
      Returns:
        the bindable variable names

    - #### bindVariableValue

          public void bindVariableValue(net.sf.saxon.s9api.QName varName,
                               net.sf.saxon.s9api.XPathSelector sel)

      Bind variable value.
      Parameters:
        `varName` - the var name
        `sel` - the sel

    - #### getNumberOfVariables

          public int getNumberOfVariables()

      Gets the number of variables.
      Returns:
        the number of variables

    - #### isCovered

          public boolean isCovered(javax.xml.namespace.QName source,
                          int aspect)

      Returns true when the variable used in the source parameter is covered.
      Parameters:
        `source` - the source
        `aspect` - the aspect
      Returns:
        true, if is covered

    - #### getXFIImplicitFilterOptimizer

          public XFIImplicitFilterOptimizer getXFIImplicitFilterOptimizer()

      Description copied from interface: `XBRLVariablesHolder`
      Returns or creates the instance of the fact variable optimizer when the fact variable is used with implicit filtering in a set with more than 2 variables.
      Specified by:
        `getXFIImplicitFilterOptimizer` in interface `XBRLVariablesHolder`
      Returns:
        instance of the XFIImplicitFilterOptimizer

    - #### getOptimizer

          public XFIImplicitFilterOptimizer getOptimizer()

      Returns the optimizer for the set. this may be null
      Returns:
        the optimizer if any was created

    - #### getUncoveredAspectsSet

          public static int getUncoveredAspectsSet(java.util.Collection<XBRLVariableResourceUse> variableUses,
                                   XBRLVariablesHolder set)

      Computes uncovered aspects in common in all variables in the set. This method is used for internal optimization purposes
      Parameters:
        `variableUses` - the variable uses
        `set` - the set
      Returns:
        the uncovered aspects set