Package net.sf.saxon.expr.instruct
Class Bindery
- java.lang.Object
-
- net.sf.saxon.expr.instruct.Bindery
-
public final class Bindery extends java.lang.Object
The Bindery class holds information about variables and their values. It is used only for global variables: local variables are held in the XPathContext object.Variables are identified by a
GlobalVariable
object. Values will always be of classSequence
.The Bindery is a run-time object, but slot numbers within the bindery are allocated to global variables at compile time. Because XSLT packages can be separately compiled, each package needs to have its own bindery.
From Saxon 9.7 there is one Bindery for the global variables in each separately-compiled package. The Bindery is no longer used to hold supplied values of global parameters, but it does hold their values after initialization, treating them as normal global variables. Management of dependencies among global variables, and checking for dynamic circularities, has been moved to the
Controller
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Bindery.FailureValue
A value that can be saved in a global variable to indicate that evaluation failed, and that subsequent attempts at evaluation should also fail
-
Constructor Summary
Constructors Constructor Description Bindery(PackageData pack)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description GroundedValue
getGlobalVariable(int slot)
Get the value of a global variable whose slot number is knownGroundedValue[]
getGlobalVariables()
Get all the global variables, as an array.GroundedValue
getGlobalVariableValue(GlobalVariable binding)
Get the value of a global variableGroundedValue
saveGlobalVariableValue(GlobalVariable binding, GroundedValue value)
Save the value of a global variable, and mark evaluation as complete.boolean
setExecuting(GlobalVariable binding)
Set/Unset a flag to indicate that a particular global variable is currently being evaluated.void
setGlobalVariable(GlobalVariable binding, GroundedValue value)
Provide a value for a global variablevoid
setNotExecuting(GlobalVariable binding)
Indicate that a global variable is not currently being evaluated
-
-
-
Constructor Detail
-
Bindery
public Bindery(PackageData pack)
-
-
Method Detail
-
setGlobalVariable
public void setGlobalVariable(GlobalVariable binding, GroundedValue value)
Provide a value for a global variable- Parameters:
binding
- identifies the variablevalue
- the value of the variable
-
setExecuting
public boolean setExecuting(GlobalVariable binding) throws XPathException
Set/Unset a flag to indicate that a particular global variable is currently being evaluated. Note that this code is not synchronized, so there is no absolute guarantee that two threads will not both evaluate the same global variable; however, apart from wasted time, it is harmless if they do.- Parameters:
binding
- the global variable in question- Returns:
- true if evaluation of the variable should proceed; false if it is found that the variable has now been evaluated in another thread.
- 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.
-
setNotExecuting
public void setNotExecuting(GlobalVariable binding)
Indicate that a global variable is not currently being evaluated- Parameters:
binding
- the global variable
-
saveGlobalVariableValue
public GroundedValue saveGlobalVariableValue(GlobalVariable binding, GroundedValue value)
Save the value of a global variable, and mark evaluation as complete.- Parameters:
binding
- the global variable in questionvalue
- the value that this thread has obtained by evaluating the variable- Returns:
- the value actually given to the variable. Exceptionally this will be different from the supplied value if another thread has evaluated the same global variable concurrently. The returned value should be used in preference, to ensure that all threads agree on the value. They could be different if for example the variable is initialized using the collection() function.
-
getGlobalVariableValue
public GroundedValue 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 GroundedValue 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.
-
getGlobalVariables
public GroundedValue[] getGlobalVariables()
Get all the global variables, as an array. This is provided for use by debuggers. The meaning of the result can be determined by use of data held in the corresponding PackageData.- Returns:
- the array of global variables.
-
-