com.ihr.xbrl.om.formula
Class XBRLFormula

java.lang.Object
  extended by com.ihr.xbrl.om.XMLFragment
      extended by com.ihr.xbrl.om.exLinks.XLinkElement
          extended by com.ihr.xbrl.om.exLinks.XBRLPointerOfARelationship
              extended by com.ihr.xbrl.om.exLinks.XBRLResource
                  extended by com.ihr.xbrl.om.formula.XBRLFormulaResource
                      extended by com.ihr.xbrl.om.formula.XBRLVariableSetResource
                          extended by com.ihr.xbrl.om.formula.XBRLFormula
All Implemented Interfaces:
XBRLRelationshipPoint, HasFormulaProcessor, HasUncoveredAspectValueResolver, StaticCheck, XBRLVariablesHolder, XMLEvaluationContextProvider, XBRLValidation, XBRLValueKey, XMLHasParent, java.lang.Cloneable, javax.xml.namespace.NamespaceContext

public class XBRLFormula
extends XBRLVariableSetResource
implements XMLEvaluationContextProvider, StaticCheck

Author:
Ignacio

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.ihr.xbrl.om.XBRLValidation
XBRLValidation.Direction
 
Field Summary
static javax.xml.namespace.QName decimals
           
static javax.xml.namespace.QName formula
           
static org.apache.log4j.Logger log
           
static javax.xml.namespace.QName precision
           
static javax.xml.namespace.QName source
           
static javax.xml.namespace.QName uncovered
           
static javax.xml.namespace.QName value
           
 
Fields inherited from class com.ihr.xbrl.om.formula.XBRLVariableSetResource
aspectModel, implicitFiltering
 
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, EMPTYRELATIONSHIPSITERATORINSTANCE, EMPTYXMLFRAGMENTITERATORINSTANCE, FACT_CONCEPT_DATATYPE, FACT_CONCEPT_LABEL, FACT_QNAME, idQName, NO_POSITION, OrderComparator, 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
XBRLFormula(XBRLFormulaProcessor proc, XBRLExtendedLink parent, net.sf.saxon.s9api.XdmNode resNode)
          Creates a new formula from a node in an extended link.
XBRLFormula(XBRLFormulaProcessor proc, XBRLResource other)
          Formulas are normally created by copying another existing resource
 
Method Summary
 XBRLInstance evaluateFormula(XBRLInstance doc, XBRLInstance instance)
          Evaluates a formula and returns an instance document containing the formula output.
 int getAllAspectsIndicated()
          Access to a bit map of flags for the aspects indicated on this formula.
 XMLFragment getEvaluationContext()
           
 java.lang.String getExpression()
          Access to the xpath expression inside this formula resource.
 boolean isTheSourceOf(XBRLFact fact)
          This method returns true if this formula is the source of a fact generation.
 void setExecutionTarget(ExecutionTargetType type)
          Set or changes the target execution for this formula.
 void staticCheck()
          Resources that has static checking implements this interface.
 void staticCheckAspectRules()
          Called during the compilation of the resource.
 
Methods inherited from class com.ihr.xbrl.om.formula.XBRLVariableSetResource
allDimensions, bindCycle, bindLastEvaluatedVariableValues, bindParameters, bindVariableValue, checkCyclicDependencies, compileFilters, compileFormulaExpression, declareVariables, getAspectModel, getBindableVariableNames, getFilters, getNumberOfVariables, getUncoveredAspectValue, getVariableResource, getVariableUse, getVariableValue, getVariableValue, isCovered, isImplicitFilter
 
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, 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, getAttribute, getAttributeQNameValue, getAttributes, getAttributeStringValue, getAttributeValue, getBase, getBase, getBaseURI, getBooleanValue, getChild, getContainer, getContainerDocumentURI, getDeclaredNamespaces, getDocument, getElements, getFragment, getFromRelationships, getFromRelationships, getFromRelationships, getFromRelationships, getId, getLang, getNamespaceURI, getNodeName, getNumberOfElements, getNumberOfFromRelationships, getNumberOfToRelationships, getOrGenerateId, getPrefix, getPrefixes, getQNameValue, getRelationshipsBases, getRelationshipsChain, getRelationshipTypes, getStaticNamespace, getStringValue, getToRelationships, getToRelationships, getToRelationships, getToRelationships, getValue, getXPathNamespaceContext, getXPathToNode, getXPathToRoot, getXPointerElementScheme, getXPointerElementScheme, getXPointerShorthandScheme, getXPointerToNode, isDead, isNamespaceDefined, objEquals, objHashCode, qNameToString, removeAttribute, removeChild, removeChild, removeFromRelationship, removeToRelationship, removeXMLChild, resetElements, resetHash, resolveHRef, resolveHRef, s_equal2, s_equal2, setAttributes, setBase, setDocument, setDocumentAndReload, setElements, setLang, setNamespaceContext, setNamespaces, setNode, setNodeName, setParent, setValue, setVariablesDefined, 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

value

public static final javax.xml.namespace.QName value

source

public static final javax.xml.namespace.QName source

decimals

public static final javax.xml.namespace.QName decimals

precision

public static final javax.xml.namespace.QName precision

formula

public static final javax.xml.namespace.QName formula

uncovered

public static final javax.xml.namespace.QName uncovered
Constructor Detail

XBRLFormula

public XBRLFormula(XBRLFormulaProcessor proc,
                   XBRLExtendedLink parent,
                   net.sf.saxon.s9api.XdmNode resNode)
            throws XFValidationException
Creates a new formula from a node in an extended link.

Parameters:
parent - XBRLExtendedLink parent of this new formula
resNode - XdmNode saxon node defined in saxon s9api
Throws:
XFValidationException
XBRLValidationException

XBRLFormula

public XBRLFormula(XBRLFormulaProcessor proc,
                   XBRLResource other)
            throws XFValidationException
Formulas are normally created by copying another existing resource

Parameters:
other - XBRLResource
Throws:
XFValidationException
XBRLValidationException
Method Detail

setExecutionTarget

public void setExecutionTarget(ExecutionTargetType type)
Set or changes the target execution for this formula. See the documentation of the ExecutionTargetType documentation. This method is used internally by the API.

Parameters:
type -

staticCheck

public void staticCheck()
                 throws XFValidationException
Description copied from interface: StaticCheck
Resources that has static checking implements this interface. During resource compilation time the static check is evaluated.

In case of errors, the staticCheck method raises XFValidationException

Specified by:
staticCheck in interface StaticCheck
Throws:
XFValidationException - if static errors occurs

staticCheckAspectRules

public void staticCheckAspectRules()
                            throws XFValidationException
Called during the compilation of the resource. This method implement the rules about checking the aspects for the formula and raise static errors if no aspect is found.

This method updates the internal variable allAspectsIndicated

Throws:
XFValidationException
See Also:
2.1.2 Aspect rules

getExpression

public java.lang.String getExpression()
Access to the xpath expression inside this formula resource.

Returns:
the expression

getAllAspectsIndicated

public int getAllAspectsIndicated()
Access to a bit map of flags for the aspects indicated on this formula. Aspects should be used later for the implicit filters.

Returns:

evaluateFormula

public XBRLInstance evaluateFormula(XBRLInstance doc,
                                    XBRLInstance instance)
                             throws XFValidationException
Evaluates a formula and returns an instance document containing the formula output.

Current version of the formula specification indicates that the formula output is just a single fact. In the opinion of the author of this code, this is just one sign of bad quality specifications.

Nothing would stop the formula authors to produce a sequence of facts as a result of a formula evaluation because the formula output can be easily enclosed inside a single instance document (containing one or a set of facts). This API has been designed this way in order to allow that possible feature in the future while provides the required functionality in the current document wording.

Parameters:
doc - the "target instance" as defined in the formula specification. This is the instance from which variable values will be obtained
instance - instance document to add generated facts to. This method will write values to instance. can be null, in this case, a new instance document is created inside this function.
Returns:
the instance parameter.
Throws:
XFValidationException - if errors occurs during the formula execution
See Also:
3 The processing model for formulae

getEvaluationContext

public XMLFragment getEvaluationContext()
Specified by:
getEvaluationContext in interface XMLEvaluationContextProvider

isTheSourceOf

public boolean isTheSourceOf(XBRLFact fact)
This method returns true if this formula is the source of a fact generation. Note this method works only if the Execution Target is set for XBRL Consistency Checks

Parameters:
fact -
Returns:
true or false


Copyright 2006-2009 Reporting Standard S.L., C/ Torrecilla del Puerto 1, 28043, Madrid, Espaņa