com.icl.saxon.expr
Class Value
public abstract class Value
A value is the result of an expression but it is also an expression in its own right
boolean | asBoolean() - Convert the value to a Boolean
|
double | asNumber() - Convert the value to a Number
|
String | asString() - Convert the value to a String value
|
boolean | compare(int operator, Value other) - Test how a Value compares to another Value under a relational comparison.
|
int | conversionPreference(Class required) - Get conversion preference for this value to a Java class.
|
Object | convertToJava(Class target) - Convert to Java object (for passing to external functions)
|
boolean | equals(Value other) - Test whether two values are equal.
|
Value | evaluate(Context context) - Evaluate the Value.
|
int | getDependencies() - Determine which aspects of the context the expression depends on.
|
protected static int | inverse(int operator) - Return the inverse of a relational operator, so that "a op b" can be
rewritten as "b inverse(op) a"
|
boolean | notEquals(Value other) - Test whether two values are not-equal.
|
protected boolean | numericCompare(int operator, double x, double y)
|
Expression | reduce(int dependencies, Context context) - Perform a partial evaluation of the expression, by eliminating specified dependencies
on the context.
|
Expression | simplify() - Simplify an expression
|
static double | stringToNumber(String s) - Static method to convert strings to numbers.
|
containsReferences , display , enumerate , evaluate , evaluateAsBoolean , evaluateAsNodeSet , evaluateAsNumber , evaluateAsString , getDataType , getDependencies , getStaticContext , indent , isContextDocumentNodeSet , make , outputStringValue , reduce , setStaticContext , simplify , usesCurrent |
ANY
public static final int ANY
- -1
BOOLEAN
public static final int BOOLEAN
Constants denoting the data types of an expression or value
- 1
NODESET
public static final int NODESET
- 4
NUMBER
public static final int NUMBER
- 2
OBJECT
public static final int OBJECT
- 6
STRING
public static final int STRING
- 3
asBoolean
public boolean asBoolean()
throws XPathException
Convert the value to a Boolean
- the value converted to a Boolean
asNumber
public double asNumber()
throws XPathException
Convert the value to a Number
- the value converted to a String
asString
public String asString()
throws XPathException
Convert the value to a String value
- the value converted to a String
compare
public boolean compare(int operator,
Value other)
throws XPathException
Test how a Value compares to another Value under a relational comparison.
Note that the method is overridden for NodeSetValue
operator
- The comparison operator, one of Tokenizer.LE, Tokenizer.LT,
Tokenizer.GE, Tokenizer.GT, Tokenizer.EQUALS, Tokenizer.NE.
conversionPreference
public int conversionPreference(Class required)
Get conversion preference for this value to a Java class. A low result
indicates higher preference.
convertToJava
public Object convertToJava(Class target)
throws XPathException
Convert to Java object (for passing to external functions)
target
- The class required by the external function
- an object of the target class
equals
public boolean equals(Value other)
throws XPathException
Test whether two values are equal. See the XSL specification: if either operand is a
nodeset, they are compared as nodesets; else if either is a boolean, they
are compared as booleans; else if either operand is a number, they are compared as numbers;
else they are compared as strings.
- a boolean giving the value of the expression, evaluated in the current context
evaluate
public Value evaluate(Context context)
throws XPathException
Evaluate the Value. Null operation, because it has already been evaluated
- evaluate in interface Expression
context
- The context (not used)
- the value, unchanged
getDependencies
public int getDependencies()
Determine which aspects of the context the expression depends on. The result is
a bitwise-or'ed value composed from constants such as Context.VARIABLES and
Context.CURRENT_NODE
- getDependencies in interface Expression
inverse
protected static final int inverse(int operator)
Return the inverse of a relational operator, so that "a op b" can be
rewritten as "b inverse(op) a"
notEquals
public boolean notEquals(Value other)
throws XPathException
Test whether two values are not-equal. Note that a!=b means the same as !(a=b) except
where either a or b is a nodeset.
- a boolean giving the value of the expression, evaluated in the current context
numericCompare
protected final boolean numericCompare(int operator,
double x,
double y)
reduce
public Expression reduce(int dependencies,
Context context)
Perform a partial evaluation of the expression, by eliminating specified dependencies
on the context.
- reduce in interface Expression
dependencies
- The dependencies to be removedcontext
- The context to be used for the partial evaluation
- a new expression that does not have any of the specified
dependencies
simplify
public Expression simplify()
Simplify an expression
- simplify in interface Expression
- the simplified expression
stringToNumber
public static double stringToNumber(String s)
Static method to convert strings to numbers. Might as well go here as anywhere else.
s
- the String to be converted
- a double representing the value of the String; if it cannot be converted,
return NaN (as required by the XSL specification)