Package org.apache.xpath.operations
Class Variable
java.lang.Object
org.apache.xpath.Expression
org.apache.xpath.operations.Variable
- All Implemented Interfaces:
Serializable,SourceLocator,PathComponent,ExpressionNode,XPathVisitable
- Direct Known Subclasses:
VariableSafeAbsRef
public class Variable extends Expression implements PathComponent
The variable reference expression executer.
- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description protected intm_indexThe index of the variable, which is either an absolute index to a global, or, if higher than the globals area, must be adjusted by adding the offset to the current stack frame.protected booleanm_isGlobalprotected QNamem_qnameThe qualified name of the variable. -
Constructor Summary
Constructors Constructor Description Variable() -
Method Summary
Modifier and Type Method Description voidcallVisitors(ExpressionOwner owner, XPathVisitor visitor)This will traverse the heararchy, calling the visitor for each member.booleandeepEquals(Expression expr)Compare this object with another object and see if they are equal, include the sub heararchy.XObjectexecute(XPathContext xctxt)Execute an expression in the XPath runtime context, and return the result of the expression.XObjectexecute(XPathContext xctxt, boolean destructiveOK)Dereference the variable, and return the reference value.voidfixupVariables(Vector vars, int globalsSize)This function is used to fixup variables from QNames to stack frame indexes at stylesheet build time.intgetAnalysisBits()Get the analysis bits for this walker, as defined in the WalkerFactory.ElemVariablegetElemVariable()Get the XSLT ElemVariable that this sub-expression references.booleangetGlobal()Set the index for the variable into the stack.intgetIndex()Set the index for the variable into the stack.QNamegetQName()Get the qualified name of the variable.booleanisPsuedoVarRef()Tell if this is a psuedo variable reference, declared by Xalan instead of by the user.booleanisStableNumber()Tell if this expression returns a stable number that will not change during iterations within the expression.voidsetIndex(int index)Set the index for the variable into the stack.voidsetIsGlobal(boolean isGlobal)Set whether or not this is a global reference.voidsetQName(QName qname)Set the qualified name of the variable.Methods inherited from class org.apache.xpath.Expression
asIterator, asIteratorRaw, asNode, assertion, bool, canTraverseOutsideSubtree, error, execute, execute, executeCharsToContentHandler, exprAddChild, exprGetChild, exprGetNumChildren, exprGetParent, exprSetParent, getColumnNumber, getExpressionOwner, getLineNumber, getPublicId, getSystemId, isNodesetExpr, isSameClass, num, warn, xstr
-
Field Details
-
m_qname
The qualified name of the variable. -
m_index
protected int m_indexThe index of the variable, which is either an absolute index to a global, or, if higher than the globals area, must be adjusted by adding the offset to the current stack frame. -
m_isGlobal
protected boolean m_isGlobal
-
-
Constructor Details
-
Variable
public Variable()
-
-
Method Details
-
setIndex
public void setIndex(int index)Set the index for the variable into the stack. For advanced use only. You must know what you are doing to use this.- Parameters:
index- a global or local index.
-
getIndex
public int getIndex()Set the index for the variable into the stack. For advanced use only.- Returns:
- index a global or local index.
-
setIsGlobal
public void setIsGlobal(boolean isGlobal)Set whether or not this is a global reference. For advanced use only.- Parameters:
isGlobal- true if this should be a global variable reference.
-
getGlobal
public boolean getGlobal()Set the index for the variable into the stack. For advanced use only.- Returns:
- true if this should be a global variable reference.
-
fixupVariables
This function is used to fixup variables from QNames to stack frame indexes at stylesheet build time.- Specified by:
fixupVariablesin classExpression- Parameters:
vars- List of QNames that correspond to variables. This list should be searched backwards for the first qualified name that corresponds to the variable reference qname. The position of the QName in the vector from the start of the vector will be its position in the stack frame (but variables above the globalsTop value will need to be offset to the current stack frame).
-
setQName
Set the qualified name of the variable.- Parameters:
qname- Must be a non-null reference to a qualified name.
-
getQName
Get the qualified name of the variable.- Returns:
- A non-null reference to a qualified name.
-
execute
Execute an expression in the XPath runtime context, and return the result of the expression.- Specified by:
executein classExpression- Parameters:
xctxt- The XPath runtime context.- Returns:
- The result of the expression in the form of a
XObject. - Throws:
TransformerException- if a runtime exception occurs.
-
execute
Dereference the variable, and return the reference value. Note that lazy evaluation will occur. If a variable within scope is not found, a warning will be sent to the error listener, and an empty nodeset will be returned.- Overrides:
executein classExpression- Parameters:
xctxt- The runtime execution context.destructiveOK- true if a "safe" object doesn't need to be returned.- Returns:
- The evaluated variable, or an empty nodeset if not found.
- Throws:
TransformerException
-
getElemVariable
Get the XSLT ElemVariable that this sub-expression references. In order for this to work, the SourceLocator must be the owning ElemTemplateElement.- Returns:
- The dereference to the ElemVariable, or null if not found.
-
isStableNumber
public boolean isStableNumber()Tell if this expression returns a stable number that will not change during iterations within the expression. This is used to determine if a proximity position predicate can indicate that no more searching has to occur.- Overrides:
isStableNumberin classExpression- Returns:
- true if the expression represents a stable number.
-
getAnalysisBits
public int getAnalysisBits()Get the analysis bits for this walker, as defined in the WalkerFactory.- Specified by:
getAnalysisBitsin interfacePathComponent- Returns:
- One of WalkerFactory#BIT_DESCENDANT, etc.
-
callVisitors
Description copied from interface:XPathVisitableThis will traverse the heararchy, calling the visitor for each member. If the called visitor method returns false, the subtree should not be called.- Specified by:
callVisitorsin interfaceXPathVisitable- Parameters:
owner- The owner of the visitor, where that path may be rewritten if needed.visitor- The visitor whose appropriate method will be called.- See Also:
XPathVisitable.callVisitors(ExpressionOwner, XPathVisitor)
-
deepEquals
Description copied from class:ExpressionCompare this object with another object and see if they are equal, include the sub heararchy.- Specified by:
deepEqualsin classExpression- Parameters:
expr- Another expression object.- Returns:
- true if this objects class and the expr object's class are the same, and the data contained within both objects are considered equal.
- See Also:
Expression.deepEquals(Expression)
-
isPsuedoVarRef
public boolean isPsuedoVarRef()Tell if this is a psuedo variable reference, declared by Xalan instead of by the user.
-