|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.saxon.expr.Expression net.sf.saxon.instruct.Instruction net.sf.saxon.instruct.GeneralVariable
public abstract class GeneralVariable
This class defines common behaviour across xsl:variable, xsl:param, and xsl:with-param; also saxon:assign
Field Summary | |
---|---|
protected int |
evaluationMode
|
protected int |
referenceCount
|
protected int |
slotNumber
|
protected StructuredQName |
variableQName
|
Fields inherited from class net.sf.saxon.expr.Expression |
---|
EVALUATE_METHOD, ITERATE_METHOD, locationId, PROCESS_METHOD, staticProperties |
Constructor Summary | |
---|---|
GeneralVariable()
Create a general variable |
Method Summary | |
---|---|
Expression |
copy()
Copy an expression. |
Item |
evaluateItem(XPathContext context)
Evaluate an expression as a single item. |
void |
explain(ExpressionPresenter out)
Diagnostic print of expression structure. |
int |
getCardinality()
Get the cardinality of the result of this instruction. |
int |
getEvaluationMode()
Get the evaluation mode of the variable |
int |
getInstructionNameCode()
Get the name of this instruction (that is xsl:variable, xsl:param etc) for diagnostics |
ItemType |
getItemType(TypeHierarchy th)
Get the type of the result of this instruction. |
int |
getLocalSlotNumber()
If this is a local variable held on the local stack frame, return the corresponding slot number. |
SequenceType |
getRequiredType()
Get the required type of this variable |
Expression |
getSelectExpression()
Get the expression to which this variable is bound |
ValueRepresentation |
getSelectValue(XPathContext context)
Evaluate the variable. |
int |
getSlotNumber()
Get the slot number allocated to this variable |
StructuredQName |
getVariableQName()
Get the name of this variable |
void |
init(Expression select,
StructuredQName qName)
Initialize the properties of the variable |
boolean |
isAssignable()
Test whether it is permitted to assign to the variable using the saxon:assign extension element. |
boolean |
isGlobal()
Indicate whether the binding is local or global. |
boolean |
isImplicitlyRequiredParam()
Ask whether this variable represents a parameter that is implicitly required, because there is no usable default value |
boolean |
isRequiredParam()
Ask whether this variable represents a required parameter |
boolean |
isTunnelParam()
Ask whether this variable represents a tunnel parameter |
SequenceIterator |
iterate(XPathContext context)
Return an Iterator to iterate over the values of a sequence. |
Iterator<Expression> |
iterateSubExpressions()
Get all the XPath expressions associated with this instruction (in XSLT terms, the expression present on attributes of the instruction, as distinct from the child instructions in a sequence construction) |
Expression |
optimize(ExpressionVisitor visitor,
ItemType contextItemType)
Perform optimisation of an expression and its subexpressions. |
protected void |
promoteInst(PromotionOffer offer)
Handle promotion offers, that is, non-local tree rewrites. |
boolean |
replaceSubExpression(Expression original,
Expression replacement)
Replace one subexpression by a replacement subexpression |
void |
setAssignable(boolean assignable)
Indicate whether this variable is assignable using saxon:assign |
void |
setImplicitlyRequiredParam(boolean requiredParam)
Indicate that this variable represents a parameter that is implicitly required (because there is no usable default value) |
void |
setReferenceCount(int refCount)
Set the nominal number of references to this variable |
void |
setRequiredParam(boolean requiredParam)
Indicate that this variable represents a required parameter |
void |
setRequiredType(SequenceType required)
Set the required type of this variable |
void |
setSelectExpression(Expression select)
Set the expression to which this variable is bound |
void |
setSlotNumber(int s)
Set the slot number of this variable |
void |
setTunnel(boolean tunnel)
Indicate whether this variable represents a tunnel parameter |
void |
setVariableQName(StructuredQName s)
Set the name of the variable |
Expression |
simplify(ExpressionVisitor visitor)
Simplify this expression |
Expression |
typeCheck(ExpressionVisitor visitor,
ItemType contextItemType)
Perform type checking of an expression and its subexpressions. |
Methods inherited from class net.sf.saxon.instruct.Instruction |
---|
assembleParams, assembleTunnelParams, computeCardinality, computeSpecialProperties, createsNewNodes, dynamicError, evaluateAsString, getConstructType, getImplementationMethod, getSourceLocator, isXSLT, process, processLeavingTail, promote |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface net.sf.saxon.expr.Binding |
---|
evaluateVariable |
Methods inherited from interface javax.xml.transform.SourceLocator |
---|
getColumnNumber, getLineNumber, getPublicId, getSystemId |
Field Detail |
---|
protected StructuredQName variableQName
protected int slotNumber
protected int referenceCount
protected int evaluationMode
Constructor Detail |
---|
public GeneralVariable()
Method Detail |
---|
public void init(Expression select, StructuredQName qName)
select
- the expression to which the variable is boundqName
- the name of the variablepublic void setSelectExpression(Expression select)
select
- the initializing expressionpublic Expression getSelectExpression()
public void setRequiredType(SequenceType required)
required
- the required typepublic SequenceType getRequiredType()
getRequiredType
in interface Binding
public void setAssignable(boolean assignable)
assignable
- true if this variable is assignablepublic void setRequiredParam(boolean requiredParam)
requiredParam
- true if this is a required parameterpublic void setImplicitlyRequiredParam(boolean requiredParam)
requiredParam
- true if this is an implicitly required parameterpublic void setTunnel(boolean tunnel)
tunnel
- true if this is a tunnel parameterpublic void setReferenceCount(int refCount)
refCount
- the nominal number of referencespublic int getEvaluationMode()
ExpressionTool
public final boolean isAssignable()
isAssignable
in interface Binding
public ItemType getItemType(TypeHierarchy th)
getItemType
in class Instruction
th
- the type hierarchy cache
public int getCardinality()
getCardinality
in class Expression
public boolean isGlobal()
Binding
isGlobal
in interface Binding
public int getLocalSlotNumber()
getLocalSlotNumber
in interface Binding
public final boolean isRequiredParam()
public final boolean isImplicitlyRequiredParam()
public final boolean isTunnelParam()
public int getInstructionNameCode()
getInstructionNameCode
in class Instruction
public Expression simplify(ExpressionVisitor visitor) throws XPathException
simplify
in class Instruction
visitor
- an expression
XPathException
public Expression typeCheck(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException
Expression
This checks statically that the operands of the expression have the correct type; if necessary it generates code to do run-time type checking or type conversion. A static type error is reported only if execution cannot possibly succeed, that is, if a run-time type error is inevitable. The call may return a modified form of the expression.
This method is called after all references to functions and variables have been resolved to the declaration of the function or variable. However, the types of such functions and variables may not be accurately known if they have not been explicitly declared.
If the implementation returns a value other than "this", then it is required to ensure that the location information in the returned expression have been set up correctly. It should not rely on the caller to do this, although for historical reasons many callers do so.
typeCheck
in class Expression
visitor
- an expression visitorcontextItemType
- the static type of "." at the point where this expression is invoked.
The parameter is set to null if it is known statically that the context item will be undefined.
If the type of the context item is not known statically, the argument is set to
Type.ITEM_TYPE
XPathException
- if an error is discovered during this phase
(typically a type error)public Expression optimize(ExpressionVisitor visitor, ItemType contextItemType) throws XPathException
Expression
This method is called after all references to functions and variables have been resolved to the declaration of the function or variable, and after all type checking has been done.
optimize
in class Expression
visitor
- an expression visitorcontextItemType
- the static type of "." at the point where this expression is invoked.
The parameter is set to null if it is known statically that the context item will be undefined.
If the type of the context item is not known statically, the argument is set to
Type.ITEM_TYPE
XPathException
- if an error is discovered during this phase
(typically a type error)public Expression copy()
copy
in class Expression
public Item evaluateItem(XPathContext context) throws XPathException
evaluateItem
in interface EvaluableItem
evaluateItem
in class Instruction
context
- The context in which the expression is to be evaluated
XPathException
- if any dynamic error occurs evaluating the
expressionpublic SequenceIterator iterate(XPathContext context) throws XPathException
iterate
in interface SequenceIterable
iterate
in class Instruction
context
- supplies the context for evaluation
XPathException
- if any dynamic error occurs evaluating the
expressionpublic ValueRepresentation getSelectValue(XPathContext context) throws XPathException
context
- the XPath dynamic context
XPathException
protected void promoteInst(PromotionOffer offer) throws XPathException
promoteInst
in class Instruction
offer
- The type of rewrite being offered
XPathException
public Iterator<Expression> iterateSubExpressions()
iterateSubExpressions
in class Expression
public boolean replaceSubExpression(Expression original, Expression replacement)
replaceSubExpression
in class Expression
original
- the original subexpressionreplacement
- the replacement subexpression
public void explain(ExpressionPresenter out)
explain
in class Expression
out
- the expression presenter used to display the structurepublic int getSlotNumber()
public void setSlotNumber(int s)
s
- the slot number, that is, the position allocated to this variable on its stack framepublic void setVariableQName(StructuredQName s)
s
- the name of the variable (a QName)public StructuredQName getVariableQName()
getVariableQName
in interface Binding
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |