public abstract class Value extends java.lang.Object implements Expression, java.io.Serializable, ValueRepresentation
| Modifier and Type | Field and Description |
|---|---|
static java.lang.Class[] |
EMPTY_CLASS_ARRAY |
EVALUATE_METHOD, ITERATE_METHOD, PROCESS_METHODEMPTY_VALUE_ARRAY| Constructor and Description |
|---|
Value() |
| Modifier and Type | Method and Description |
|---|---|
static Item |
asItem(ValueRepresentation value)
Static method to make an Item from a Value
|
static SequenceIterator |
asIterator(ValueRepresentation val,
XPathContext context)
Static method to get an Iterator over any ValueRepresentation (which may be either a Value
or a NodeInfo
|
static Value |
asValue(ValueRepresentation val)
Static method to make a Value from a given Item (which may be either an AtomicValue
or a NodeInfo
|
void |
checkPermittedContents(SchemaType parentType,
StaticContext env,
boolean whole)
Check statically that the results of the expression are capable of constructing the content
of a given schema type.
|
static java.lang.Object |
convert(Item item)
Internal method to convert an XPath value to a Java object.
|
static Value |
convertJavaObjectToXPath(java.lang.Object object,
SequenceType requiredType,
Configuration config)
Convert a Java object to an XPath value.
|
java.lang.Object |
convertToJava(java.lang.Class target,
XPathContext context)
Convert to Java object (for passing to external functions)
|
void |
display(int level,
java.io.PrintStream out,
Configuration config)
Diagnostic display of the expression
|
boolean |
effectiveBooleanValue(XPathContext context)
Get the effective boolean value of the expression.
|
boolean |
equals(java.lang.Object obj)
Compare two (sequence) values for equality.
|
java.lang.String |
evaluateAsString(XPathContext context)
Evaluate an expression as a String.
|
Item |
evaluateItem(XPathContext context)
Evaluate as a singleton item (or empty sequence).
|
int |
getCardinality()
Determine the cardinality
|
int |
getDependencies()
Determine which aspects of the context the expression depends on.
|
ItemType |
getItemType(TypeHierarchy th)
Determine the data type of the items in the expression, if possible
|
static SequenceIterator |
getIterator(ValueRepresentation val)
Get a SequenceIterator over a ValueRepresentation
|
int |
getLength()
Get the length of the sequence
|
Container |
getParentExpression()
Get the expression that immediately contains this expression.
|
int |
getSpecialProperties()
Get the static properties of this expression (other than its type).
|
java.lang.String |
getStringValue()
Convert the value to a string, using the serialization rules.
|
java.lang.CharSequence |
getStringValueCS()
Get the value of the item as a CharSequence.
|
int |
hashCode()
Return a hash code to support the equals() function
|
Item |
itemAt(int n)
Get the n'th item in the sequence (starting from 0).
|
java.util.Iterator |
iterateSubExpressions()
Get the sub-expressions of this expression.
|
static QNameValue |
makeQNameValue(java.lang.Object object,
Configuration config)
Temporary method to make a QNameValue from a JAXP 1.3 QName, without creating a compile-time link
to the JDK 1.5 QName class
|
Expression |
optimize(Optimizer opt,
StaticContext env,
ItemType contextItemType)
Optimize an expression
|
void |
process(XPathContext context)
Process the value as an instruction, without returning any tail calls
|
Expression |
promote(PromotionOffer offer)
Offer promotion for this subexpression.
|
Value |
reduce()
Reduce a value to its simplest form.
|
Expression |
simplify(StaticContext env)
Simplify an expression
|
static double |
stringToNumber(java.lang.CharSequence s)
Static method to convert strings to numbers.
|
java.lang.String |
toString()
Convert to a string for diagnostic output
|
Expression |
typeCheck(StaticContext env,
ItemType contextItemType)
TypeCheck an expression
|
clone, finalize, getClass, notify, notifyAll, wait, wait, waitgetImplementationMethod, iteratepublic static Value asValue(ValueRepresentation val)
val - The supplied value, or null, indicating the empty sequence.public static Item asItem(ValueRepresentation value) throws XPathException
value - the value to be convertedXPathException - if the Value contains multiple itemspublic static SequenceIterator asIterator(ValueRepresentation val, XPathContext context) throws XPathException
val - The supplied value, or null, indicating the empty sequence.context - The evaluation context. This may be null. It should always be possible to
iterate over a value without supplying a context, but sometimes the context
can provide access to better error informationXPathExceptionpublic static double stringToNumber(java.lang.CharSequence s)
throws java.lang.NumberFormatException
s - the String to be convertedjava.lang.NumberFormatException - if the value cannot be convertedpublic static SequenceIterator getIterator(ValueRepresentation val) throws XPathException
XPathExceptionpublic java.lang.CharSequence getStringValueCS()
throws XPathException
getStringValueCS in interface ValueRepresentationXPathException - The method can fail if evaluation of the value
has been deferred, and if a failure occurs during the deferred evaluation.
No failure is possible in the case of an AtomicValue or a Node.public final Expression simplify(StaticContext env)
simplify in interface Expressionenv - the static contextpublic final Expression typeCheck(StaticContext env, ItemType contextItemType)
typeCheck in interface Expressionenv - the static context of the expressioncontextItemType - the static type of "." at the point where this expression is invoked.
The parameter is set to null if it is known statically that the context item will be undefined.
If the type of the context item is not known statically, the argument is set to
Type.ITEM_TYPEpublic final Expression optimize(Optimizer opt, StaticContext env, ItemType contextItemType)
optimize in interface Expressionopt - the optimizer in use. This provides access to supporting functions; it also allows
different optimization strategies to be used in different circumstances.env - the static context of the expressioncontextItemType - the static type of "." at the point where this expression is invoked.
The parameter is set to null if it is known statically that the context item will be undefined.
If the type of the context item is not known statically, the argument is set to
Type.ITEM_TYPEpublic ItemType getItemType(TypeHierarchy th)
getItemType in interface Expressionth - The TypeHierarchy. Can be null if the target is an AtomicValue.public int getCardinality()
getCardinality in interface ExpressionStaticProperty.ALLOWS_ONE,
StaticProperty.ALLOWS_ZERO_OR_MORE, StaticProperty.ALLOWS_ZERO_OR_ONE,
StaticProperty.ALLOWS_ONE_OR_MORE, StaticProperty.EMPTY. This default
implementation returns ZERO_OR_MORE (which effectively gives no
information).public final java.util.Iterator iterateSubExpressions()
iterateSubExpressions in interface Expressionpublic final Container getParentExpression()
getParentExpression in interface Expressionpublic int getSpecialProperties()
StaticProperty.NON_CREATIVE.getSpecialProperties in interface ExpressionStaticProperty.NON_CREATIVEpublic final Expression promote(PromotionOffer offer)
promote in interface Expressionoffer - details of the offer, for example the offer to move
expressions that don't depend on the context to an outer level in
the containing expressionpublic final int getDependencies()
getDependencies in interface Expressionpublic Item itemAt(int n) throws XPathException
XPathExceptionpublic int getLength()
throws XPathException
XPathExceptionpublic Item evaluateItem(XPathContext context) throws XPathException
evaluateItem in interface Expressioncontext - The context in which the expression is to be evaluated. Note that this
context must contain a stackframe with sufficient slots to allow evaluation of any
variables contained in the expression (including variables allocated internally
by the optimizer)XPathException - if any dynamic error occurs evaluating the
expressionpublic void process(XPathContext context) throws XPathException
process in interface Expressioncontext - The dynamic context, giving access to the current node,
the current variables, etc.XPathExceptionpublic java.lang.String getStringValue()
throws XPathException
getStringValue in interface ValueRepresentationXPathException - The method can fail if evaluation of the value
has been deferred, and if a failure occurs during the deferred evaluation.
No failure is possible in the case of an AtomicValue.public java.lang.String evaluateAsString(XPathContext context) throws XPathException
evaluateAsString in interface Expressioncontext - The context in which the expression is to be evaluatedXPathException - if any dynamic error occurs evaluating the
expressionjava.lang.ClassCastException - if the result type of the
expression is not xs:string?public boolean effectiveBooleanValue(XPathContext context) throws XPathException
effectiveBooleanValue in interface Expressioncontext - The context in which the expression is to be evaluatedXPathException - if any dynamic error occurs evaluating the
expressionpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic void checkPermittedContents(SchemaType parentType, StaticContext env, boolean whole) throws XPathException
checkPermittedContents in interface ExpressionparentType - The schema typeenv - the static contextwhole - XPathException - if the expression doesn't match the required content typepublic Value reduce() throws XPathException
XPathExceptionpublic java.lang.Object convertToJava(java.lang.Class target,
XPathContext context)
throws XPathException
XPathExceptionpublic void display(int level,
java.io.PrintStream out,
Configuration config)
display in interface Expressionlevel - indentation level for this expressionout - Output destinationpublic static Value convertJavaObjectToXPath(java.lang.Object object, SequenceType requiredType, Configuration config) throws XPathException
object - The Java object to be convertedrequiredType - The required type of the result (if known)config - The Configuration: may be null, in which case certain kinds of object
(eg. DOM nodes) cannot be handledXPathExceptionpublic static QNameValue makeQNameValue(java.lang.Object object, Configuration config)
object - an instance of javax.xml.namespace.QNamepublic java.lang.String toString()
toString in class java.lang.Objectpublic static java.lang.Object convert(Item item) throws XPathException
XPathException