Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## net.sf.saxon.expr.instruct
Class GeneralVariable

    java.lang.Object
      net.sf.saxon.expr.instruct.GeneralVariable

All Implemented Interfaces:
  SourceLocator, Binding

Direct Known Subclasses:
  GlobalVariable, LocalParam, LocalVariable, WithParam

    public abstract class GeneralVariable

extends Object
implements Binding, SourceLocator

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`

Constructor Summary
`GeneralVariable()` Create a general variable

Method Summary
`void` | `addReference(boolean isLoopingReference)` Register a variable reference that refers to the variable bound in this expression
`void` | `checkAgainstRequiredType(ExpressionVisitor visitor)` Check the select expression against the required type.
`void` | `computeEvaluationMode()`
`Expression` | `copy()` Copy an expression.
`void` | `explain(ExpressionPresenter out)` Diagnostic print of expression structure.
`int` | `getCardinality()` Get the cardinality of the result of this instruction.
`int` | `getColumnNumber()` Get the column number of the expression
`Container` | `getContainer()` Get the container in which this expression is located.
`int` | `getEvaluationMode()` Get the evaluation mode of the variable
`Executable` | `getExecutable()` Get the executable containing this expression
`int` | `getInstructionNameCode()` Get the name of this instruction (that is xsl:variable, xsl:param etc) for diagnostics
`IntegerValue[]` | `getIntegerBoundsForVariable()` If the variable is bound to an integer, get the minimum and maximum possible values.
`int` | `getLineNumber()` Get the line number of the expression
`int` | `getLocalSlotNumber()` If this is a local variable held on the local stack frame, return the corresponding slot number.
`int` | `getLocationId()` Get the location ID of the expression
`LocationProvider` | `getLocationProvider()` Get the LocationProvider allowing location identifiers to be resolved.
`String` | `getPublicId()` Get the publicId of the module containing the expression (to satisfy the SourceLocator interface)
`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
`String` | `getSystemId()` Get the systemId of the module containing the expression
`String` | `getSystemId(long locationId)`
`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
`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)
`void` | `optimize(ExpressionVisitor visitor, ExpressionVisitor.ContextItemType contextItemType)`
`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` | `setContainer(Container container)` Mark a variable as being in a given Container.
`void` | `setImplicitlyRequiredParam(boolean requiredParam)` Indicate that this variable represents a parameter that is implicitly required (because there is no usable default value)
`void` | `setLocationId(int id)` Set the location ID on an expression.
`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
`void` | `simplify(ExpressionVisitor visitor)` Simplify this variable
`void` | `typeCheck(ExpressionVisitor visitor, ExpressionVisitor.ContextItemType contextItemType)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface net.sf.saxon.expr.Binding
`evaluateVariable`

Field Detail

### variableQName

    protected StructuredQName variableQName

### slotNumber

    protected int slotNumber

### referenceCount

    protected int referenceCount

### evaluationMode

    protected int evaluationMode

Constructor Detail

### GeneralVariable

    public GeneralVariable()

  Create a general variable

Method Detail

### init

    public void init(Expression select,
                     StructuredQName qName)

  Initialize the properties of the variable

  Parameters:
    `select` - the expression to which the variable is bound
    `qName` - the name of the variable

### setContainer

    public void setContainer(Container container)

  Mark a variable as being in a given Container. This link is used primarily for diagnostics: the container links to the location map held in the executable.

  This affects the expression and all its subexpressions. Any subexpressions that are not in the same container are marked with the new container, and this proceeds recursively. However, any subexpression that is already in the correct container is not modified.

  Parameters:
    `container` - The container of this expression.

### getContainer

    public Container getContainer()

  Get the container in which this expression is located. This will usually be a top-level construct such as a function or global variable, and XSLT template, or an XQueryExpression. In the case of free-standing XPath expressions it will be the StaticContext object

  Returns:
    the expression's container

### setLocationId

    public void setLocationId(int id)

  Set the location ID on an expression.

  Parameters:
    `id` - the location id

### getLocationId

    public final int getLocationId()

  Get the location ID of the expression

  Returns:
    a location identifier, which can be turned into real location information by reference to a location provider

### getLineNumber

    public int getLineNumber()

  Get the line number of the expression

  Specified by:
    `getLineNumber` in interface `SourceLocator`

### getColumnNumber

    public int getColumnNumber()

  Get the column number of the expression

  Specified by:
    `getColumnNumber` in interface `SourceLocator`

### getSystemId

    public String getSystemId()

  Get the systemId of the module containing the expression

  Specified by:
    `getSystemId` in interface `SourceLocator`

### getPublicId

    public final String getPublicId()

  Get the publicId of the module containing the expression (to satisfy the SourceLocator interface)

  Specified by:
    `getPublicId` in interface `SourceLocator`

### getExecutable

    public Executable getExecutable()

  Get the executable containing this expression

  Returns:
    the containing Executable

### getLocationProvider

    public LocationProvider getLocationProvider()

  Get the LocationProvider allowing location identifiers to be resolved.

  Returns:
    the LocationProvider used to turn the location id into real location information

### getSystemId

    public String getSystemId(long locationId)

### setSelectExpression

    public void setSelectExpression(Expression select)

  Set the expression to which this variable is bound

  Parameters:
    `select` - the initializing expression

### getSelectExpression

    public Expression getSelectExpression()

  Get the expression to which this variable is bound

  Returns:
    the initializing expression

### setRequiredType

    public void setRequiredType(SequenceType required)

  Set the required type of this variable

  Parameters:
    `required` - the required type

### getRequiredType

    public SequenceType getRequiredType()

  Get the required type of this variable

  Specified by:
    `getRequiredType` in interface `Binding`
  Returns:
    the required type

### getIntegerBoundsForVariable

    public IntegerValue[] getIntegerBoundsForVariable()

  If the variable is bound to an integer, get the minimum and maximum possible values. Return null if unknown or not applicable

  Specified by:
    `getIntegerBoundsForVariable` in interface `Binding`
  Returns:
    a pair of integers containing the minimum and maximum values for the integer value; or null if the value is not an integer or the range is unknown

### setAssignable

    public void setAssignable(boolean assignable)

  Indicate whether this variable is assignable using saxon:assign

  Parameters:
    `assignable` - true if this variable is assignable

### setRequiredParam

    public void setRequiredParam(boolean requiredParam)

  Indicate that this variable represents a required parameter

  Parameters:
    `requiredParam` - true if this is a required parameter

### setImplicitlyRequiredParam

    public void setImplicitlyRequiredParam(boolean requiredParam)

  Indicate that this variable represents a parameter that is implicitly required (because there is no usable default value)

  Parameters:
    `requiredParam` - true if this is an implicitly required parameter

### setTunnel

    public void setTunnel(boolean tunnel)

  Indicate whether this variable represents a tunnel parameter

  Parameters:
    `tunnel` - true if this is a tunnel parameter

### setReferenceCount

    public void setReferenceCount(int refCount)

  Set the nominal number of references to this variable

  Parameters:
    `refCount` - the nominal number of references

### getEvaluationMode

    public int getEvaluationMode()

  Get the evaluation mode of the variable

  Returns:
    the evaluation mode (a constant in `ExpressionTool`

### isAssignable

    public final boolean isAssignable()

  Test whether it is permitted to assign to the variable using the saxon:assign extension element. This will only be true if the extra attribute saxon:assignable="yes" is present.

  Specified by:
    `isAssignable` in interface `Binding`
  Returns:
    true if the binding is assignable

### getCardinality

    public int getCardinality()

  Get the cardinality of the result of this instruction. An xsl:variable instruction returns nothing, so the type is empty.

  Returns:
    the empty cardinality.

### isGlobal

    public boolean isGlobal()

  Description copied from interface: `Binding`
  Indicate whether the binding is local or global. A global binding is one that has a fixed value for the life of a query or transformation; any other binding is local.

  Specified by:
    `isGlobal` in interface `Binding`
  Returns:
    true if the binding is global

### getLocalSlotNumber

    public int getLocalSlotNumber()

  If this is a local variable held on the local stack frame, return the corresponding slot number. In other cases, return -1.

  Specified by:
    `getLocalSlotNumber` in interface `Binding`
  Returns:
    the slot number on the local stack frame

### isRequiredParam

    public final boolean isRequiredParam()

  Ask whether this variable represents a required parameter

  Returns:
    true if this is a required parameter

### isImplicitlyRequiredParam

    public final boolean isImplicitlyRequiredParam()

  Ask whether this variable represents a parameter that is implicitly required, because there is no usable default value

  Returns:
    true if this variable is an implicitly required parameter

### isTunnelParam

    public final boolean isTunnelParam()

  Ask whether this variable represents a tunnel parameter

  Returns:
    true if this is a tunnel parameter

### getInstructionNameCode

    public int getInstructionNameCode()

  Get the name of this instruction (that is xsl:variable, xsl:param etc) for diagnostics

  Returns:
    the name of this instruction, as a name pool name code

### simplify

    public void simplify(ExpressionVisitor visitor)
                  throws XPathException

  Simplify this variable

  Parameters:
    `visitor` - an expression
  Throws:
    `XPathException` - if a failure occurs

### typeCheck

    public void typeCheck(ExpressionVisitor visitor,
                          ExpressionVisitor.ContextItemType contextItemType)
                   throws XPathException

  Throws:
    `XPathException`

### optimize

    public void optimize(ExpressionVisitor visitor,
                         ExpressionVisitor.ContextItemType contextItemType)
                  throws XPathException

  Throws:
    `XPathException`

### computeEvaluationMode

    public void computeEvaluationMode()

### copy

    public Expression copy()

  Copy an expression. This makes a deep copy.

  Returns:
    the copy of the original expression

### addReference

    public void addReference(boolean isLoopingReference)

  Description copied from interface: `Binding`
  Register a variable reference that refers to the variable bound in this expression

  Specified by:
    `addReference` in interface `Binding`
  Parameters:
    `isLoopingReference` - - true if the reference occurs within a loop, such as the predicate of a filter expression

### checkAgainstRequiredType

    public void checkAgainstRequiredType(ExpressionVisitor visitor)
                                  throws XPathException

  Check the select expression against the required type.

  Parameters:
    `visitor` - an expression visitor
  Throws:
    `XPathException` - if the check fails

### getSelectValue

    public ValueRepresentation getSelectValue(XPathContext context)
                                       throws XPathException

  Evaluate the variable. That is, get the value of the select expression if present or the content of the element otherwise, either as a tree or as a sequence

  Parameters:
    `context` - the XPath dynamic context
  Returns:
    the result of evaluating the variable
  Throws:
    `XPathException` - if evaluation of the select expression fails with a dynamic error

### iterateSubExpressions

    public 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)

  Returns:
    an iterator over all the contained expressions (in practice, the select expression)

### replaceSubExpression

    public boolean replaceSubExpression(Expression original,
                                        Expression replacement)

  Replace one subexpression by a replacement subexpression

  Parameters:
    `original` - the original subexpression
    `replacement` - the replacement subexpression
  Returns:
    true if the original subexpression is found

### explain

    public void explain(ExpressionPresenter out)

  Diagnostic print of expression structure. The abstract expression tree is written to the supplied output destination.

  Parameters:
    `out` - the object used to present the output

### getSlotNumber

    public int getSlotNumber()

  Get the slot number allocated to this variable

  Returns:
    the slot number, that is the position allocated to the variable on its stack frame

### setSlotNumber

    public void setSlotNumber(int s)

  Set the slot number of this variable

  Parameters:
    `s` - the slot number, that is, the position allocated to this variable on its stack frame

### setVariableQName

    public void setVariableQName(StructuredQName s)

  Set the name of the variable

  Parameters:
    `s` - the name of the variable (a QName)

### getVariableQName

    public StructuredQName getVariableQName()

  Get the name of this variable

  Specified by:
    `getVariableQName` in interface `Binding`
  Returns:
    the name of this variable (a QName)

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright (c) 2004-2011 Saxonica Limited. All rights reserved.