net.sf.saxon.instruct.ParameterSet Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of saxon9 Show documentation
Show all versions of saxon9 Show documentation
Provides a basic XSLT 2.0 and XQuery 1.0 processor (W3C Recommendations,
January 2007). Command line interfaces and implementations of several
Java APIs (DOM, XPath, s9api) are also included.
The newest version!
package net.sf.saxon.instruct;
import net.sf.saxon.om.ValueRepresentation;
import net.sf.saxon.trans.XPathException;
import net.sf.saxon.value.Closure;
/**
* A ParameterSet is a set of parameters supplied when calling a template.
* It is a collection of id-value pairs, the ids being numeric aliases for the parameter name,
* unique within a stylesheet
*/
public class ParameterSet {
private int[] keys;
private ValueRepresentation[] values;
private int used = 0;
public static ParameterSet EMPTY_PARAMETER_SET = new ParameterSet(0);
/**
* Create an empty parameter set
*/
public ParameterSet() {
this(10);
}
/**
* Create a parameter set specifying the initial capacity
*/
public ParameterSet(int capacity) {
keys = new int[capacity];
values = new ValueRepresentation[capacity];
}
/**
* Create a parameter set as a copy of an existing parameter set
*/
public ParameterSet(ParameterSet existing, int extra) {
this(existing.used + extra);
for (int i=0; i keys.length) {
int newlength = (used<=5 ? 10 : used*2);
int[] newkeys = new int[newlength];
ValueRepresentation[] newvalues = new ValueRepresentation[newlength];
System.arraycopy(values, 0, newvalues, 0, used);
System.arraycopy(keys, 0, newkeys, 0, used);
values = newvalues;
keys = newkeys;
}
keys[used] = id;
values[used++] = value;
}
/**
* Get a parameter
*
* @param id The numeric parameter id, representing its name.
* @return The value of the parameter, or null if not defined
*/
public ValueRepresentation get (int id) {
for (int i=0; i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy