net.sf.saxon.expr.instruct.Bindery Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of saxon-he Show documentation
Show all versions of saxon-he Show documentation
An OSGi bundle for Saxon-HE
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2013 Saxonica Limited.
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
// This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
package net.sf.saxon.expr.instruct;
import net.sf.saxon.Configuration;
import net.sf.saxon.Controller;
import net.sf.saxon.expr.XPathContext;
import net.sf.saxon.om.*;
import net.sf.saxon.trans.SaxonErrorCode;
import net.sf.saxon.trans.XPathException;
import net.sf.saxon.value.SequenceExtent;
import net.sf.saxon.value.SequenceType;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.*;
/**
* 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.
*/
public final class Bindery {
private Sequence[] globals; // values of global variables and parameters
private long[] busy; // set to current thread id while variable is being evaluated
private GlobalParameterSet globalParameters; // supplied global parameters
private SlotManager globalVariableMap; // contains the mapping of variable names to slot numbers
private Map> dependencies =
new HashMap>();
private boolean applyConversionRules = true;
/**
* Define how many slots are needed for global variables
* @param map the SlotManager that keeps track of slot allocation for global variables.
*/
public void allocateGlobals(SlotManager map) {
globalVariableMap = map;
int n = map.getNumberOfVariables()+1;
globals = new Sequence[n];
busy = new long[n];
for (int i=0; i transitiveDependencies = dependencies.get(two);
if (transitiveDependencies != null) {
if (transitiveDependencies.contains(one)) {
throw new XPathException.Circularity("Circular dependency among variables: "
+ one.getVariableQName().getDisplayName() + " depends on the value of "
+ two.getVariableQName().getDisplayName() + ", which depends directly or indirectly on the value of "
+ one.getVariableQName().getDisplayName());
}
for (GlobalVariable var : transitiveDependencies) {
// register the transitive dependencies
registerDependency(one, var);
}
}
Set existingDependencies = dependencies.get(one);
if (existingDependencies == null) {
existingDependencies = new HashSet();
dependencies.put(one, existingDependencies);
}
existingDependencies.add(two);
}
}