Package net.sf.saxon.instruct
Class Bindery
- java.lang.Object
-
- net.sf.saxon.instruct.Bindery
-
public final class Bindery extends java.lang.Object
The Bindery class holds information about variables and their values. From Saxon 8.1, it is used only for global variables: local variables are now held in the XPathContext object. Variables are identified by a Binding object. Values will always be of class Value.
-
-
Constructor Summary
Constructors Constructor Description Bindery()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
allocateGlobals(SlotManager map)
Define how many slots are needed for global variablesstatic Value
applyFunctionConversionRules(ValueRepresentation value, SequenceType requiredType, XPathContext context)
Apply the function conversion rulesvoid
assignGlobalVariable(GlobalVariable binding, ValueRepresentation value)
Assign a new value to a global variable.void
defineGlobalParameters(GlobalParameterSet params)
Define global parametersvoid
defineGlobalVariable(GlobalVariable binding, ValueRepresentation value)
Provide a value for a global variableValueRepresentation
getGlobalVariable(int slot)
Get the value of a global variable whose slot number is knownSlotManager
getGlobalVariableMap()
Get the Global Variable Map, containing the mapping of variable names (fingerprints) to slot numbers.ValueRepresentation[]
getGlobalVariables()
Get all the global variables, as an array.ValueRepresentation
getGlobalVariableValue(GlobalVariable binding)
Get the value of a global variablevoid
setExecuting(GlobalVariable binding, boolean executing)
Set/Unset a flag to indicate that a particular global variable is currently being evaluated.void
setGlobalVariable(int slot, ValueRepresentation value)
Set the value of a global variable whose slot number is knownboolean
useGlobalParameter(StructuredQName qName, int slot, SequenceType requiredType, XPathContext context)
Use global parameter.
-
-
-
Method Detail
-
allocateGlobals
public void allocateGlobals(SlotManager map)
Define how many slots are needed for global variables- Parameters:
map
- the SlotManager that keeps track of slot allocation for global variables.
-
defineGlobalParameters
public void defineGlobalParameters(GlobalParameterSet params)
Define global parameters- Parameters:
params
- The ParameterSet passed in by the user, eg. from the command line
-
useGlobalParameter
public boolean useGlobalParameter(StructuredQName qName, int slot, SequenceType requiredType, XPathContext context) throws XPathException
Use global parameter. This is called when a global xsl:param element is processed. If a parameter of the relevant name was supplied, it is bound to the xsl:param element. Otherwise the method returns false, so the xsl:param default will be evaluated.- Parameters:
qName
- The name of the parameterslot
- The slot number allocated to the parameterrequiredType
- The declared type of the parametercontext
- the XPath dynamic evaluation context- Returns:
- true if a parameter of this name was supplied, false if not
- Throws:
XPathException
-
applyFunctionConversionRules
public static Value applyFunctionConversionRules(ValueRepresentation value, SequenceType requiredType, XPathContext context) throws XPathException
Apply the function conversion rules- Parameters:
value
- a value to be convertedrequiredType
- the required typecontext
- the conversion context- Returns:
- the converted value
- Throws:
XPathException
- if the value cannot be converted to the required type
-
defineGlobalVariable
public void defineGlobalVariable(GlobalVariable binding, ValueRepresentation value)
Provide a value for a global variable- Parameters:
binding
- identifies the variablevalue
- the value of the variable
-
setExecuting
public void setExecuting(GlobalVariable binding, boolean executing) throws XPathException
Set/Unset a flag to indicate that a particular global variable is currently being evaluated.- Parameters:
binding
- the global variable in questionexecuting
- true when we start evaluating the variable, false when evaluation has finished- Throws:
XPathException
- If an attempt is made to set the flag when it is already set, this means the definition of the variable is circular.
-
getGlobalVariableValue
public ValueRepresentation getGlobalVariableValue(GlobalVariable binding)
Get the value of a global variable- Parameters:
binding
- the Binding that establishes the unique instance of the variable- Returns:
- the Value of the variable if defined, null otherwise.
-
getGlobalVariable
public ValueRepresentation getGlobalVariable(int slot)
Get the value of a global variable whose slot number is known- Parameters:
slot
- the slot number of the required variable- Returns:
- the Value of the variable if defined, null otherwise.
-
setGlobalVariable
public void setGlobalVariable(int slot, ValueRepresentation value)
Set the value of a global variable whose slot number is known- Parameters:
slot
- the slot number of the required variablevalue
- the Value of the variable if defined, null otherwise.
-
assignGlobalVariable
public void assignGlobalVariable(GlobalVariable binding, ValueRepresentation value)
Assign a new value to a global variable. Supports saxon:assign.- Parameters:
binding
- identifies the global variable or parametervalue
- the value to be assigned to the variable
-
getGlobalVariableMap
public SlotManager getGlobalVariableMap()
Get the Global Variable Map, containing the mapping of variable names (fingerprints) to slot numbers. This is provided for use by debuggers.- Returns:
- the SlotManager containing information about the assignment of slot numbers to global variables and parameters
-
getGlobalVariables
public ValueRepresentation[] getGlobalVariables()
Get all the global variables, as an array. This is provided for use by debuggers that know the layout of the global variables within the array.- Returns:
- the array of global varaibles.
-
-