Package com.icl.saxon.expr
Class Value
- java.lang.Object
-
- com.icl.saxon.expr.Expression
-
- com.icl.saxon.expr.Value
-
- Direct Known Subclasses:
BooleanValue,NodeSetValue,NumericValue,ObjectValue,StringValue
public abstract class Value extends Expression
A value is the result of an expression but it is also an expression in its own right
-
-
Field Summary
Fields Modifier and Type Field Description static intANYstatic intBOOLEANConstants denoting the data types of an expression or valuestatic intNODESETstatic intNUMBERstatic intOBJECTstatic intSTRING-
Fields inherited from class com.icl.saxon.expr.Expression
staticContext
-
-
Constructor Summary
Constructors Constructor Description Value()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract booleanasBoolean()Convert the value to a Booleanabstract doubleasNumber()Convert the value to a Numberabstract java.lang.StringasString()Convert the value to a String valuebooleancompare(int operator, Value other)Test how a Value compares to another Value under a relational comparison.abstract intconversionPreference(java.lang.Class required)Get conversion preference for this value to a Java class.abstract java.lang.ObjectconvertToJava(java.lang.Class target)Convert to Java object (for passing to external functions)booleanequals(Value other)Test whether two values are equal.Valueevaluate(Context context)Evaluate the Value.intgetDependencies()Determine which aspects of the context the expression depends on.protected static intinverse(int operator)Return the inverse of a relational operator, so that "a op b" can be rewritten as "b inverse(op) a"booleannotEquals(Value other)Test whether two values are not-equal.protected booleannumericCompare(int operator, double x, double y)Expressionreduce(int dependencies, Context context)Perform a partial evaluation of the expression, by eliminating specified dependencies on the context.Expressionsimplify()Simplify an expressionstatic doublestringToNumber(java.lang.String s)Static method to convert strings to numbers.-
Methods inherited from class com.icl.saxon.expr.Expression
containsReferences, display, enumerate, evaluateAsBoolean, evaluateAsNodeSet, evaluateAsNumber, evaluateAsString, getDataType, getStaticContext, indent, isContextDocumentNodeSet, make, outputStringValue, setStaticContext, usesCurrent
-
-
-
-
Field Detail
-
BOOLEAN
public static final int BOOLEAN
Constants denoting the data types of an expression or value- See Also:
- Constant Field Values
-
NUMBER
public static final int NUMBER
- See Also:
- Constant Field Values
-
STRING
public static final int STRING
- See Also:
- Constant Field Values
-
NODESET
public static final int NODESET
- See Also:
- Constant Field Values
-
OBJECT
public static final int OBJECT
- See Also:
- Constant Field Values
-
ANY
public static final int ANY
- See Also:
- Constant Field Values
-
-
Method Detail
-
stringToNumber
public static double stringToNumber(java.lang.String s)
Static method to convert strings to numbers. Might as well go here as anywhere else.- Parameters:
s- the String to be converted- Returns:
- a double representing the value of the String; if it cannot be converted, return NaN (as required by the XSL specification)
-
evaluate
public Value evaluate(Context context) throws XPathException
Evaluate the Value. Null operation, because it has already been evaluated- Specified by:
evaluatein classExpression- Parameters:
context- The context (not used)- Returns:
- the value, unchanged
- Throws:
XPathException
-
simplify
public Expression simplify()
Simplify an expression- Overrides:
simplifyin classExpression- Returns:
- the simplified expression
-
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- Specified by:
getDependenciesin classExpression
-
asString
public abstract java.lang.String asString() throws XPathExceptionConvert the value to a String value- Returns:
- the value converted to a String
- Throws:
XPathException
-
asNumber
public abstract double asNumber() throws XPathExceptionConvert the value to a Number- Returns:
- the value converted to a String
- Throws:
XPathException
-
asBoolean
public abstract boolean asBoolean() throws XPathExceptionConvert the value to a Boolean- Returns:
- the value converted to a Boolean
- Throws:
XPathException
-
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.- Returns:
- a boolean giving the value of the expression, evaluated in the current context
- Throws:
XPathException
-
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.- Returns:
- a boolean giving the value of the expression, evaluated in the current context
- Throws:
XPathException
-
compare
public boolean compare(int operator, Value other) throws XPathExceptionTest how a Value compares to another Value under a relational comparison. Note that the method is overridden for NodeSetValue- Parameters:
operator- The comparison operator, one of Tokenizer.LE, Tokenizer.LT, Tokenizer.GE, Tokenizer.GT, Tokenizer.EQUALS, Tokenizer.NE.- Throws:
XPathException
-
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"
-
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.- Specified by:
reducein classExpression- Parameters:
dependencies- The dependencies to be removedcontext- The context to be used for the partial evaluation- Returns:
- a new expression that does not have any of the specified dependencies
-
convertToJava
public abstract java.lang.Object convertToJava(java.lang.Class target) throws XPathExceptionConvert to Java object (for passing to external functions)- Parameters:
target- The class required by the external function- Returns:
- an object of the target class
- Throws:
XPathException
-
conversionPreference
public abstract int conversionPreference(java.lang.Class required)
Get conversion preference for this value to a Java class. A low result indicates higher preference.
-
-