|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.saxon.value.Value
A value is the result of an expression but it is also an expression in its own right. Note that every value can be regarded as a sequence - in many cases, a sequence of length one.
Field Summary | |
static java.lang.Class[] |
EMPTY_CLASS_ARRAY
|
Fields inherited from interface net.sf.saxon.expr.Expression |
EVALUATE_METHOD, ITERATE_METHOD, PROCESS_METHOD |
Fields inherited from interface net.sf.saxon.om.ValueRepresentation |
EMPTY_VALUE_ARRAY |
Constructor Summary | |
Value()
|
Method Summary | |
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.CharSequence |
collapseWhitespace(java.lang.CharSequence in)
Collapse whitespace as defined in XML Schema |
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,
NamePool pool,
java.io.PrintStream out)
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. |
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 |
static java.lang.CharSequence |
normalizeWhitespace(java.lang.CharSequence in)
Normalize whitespace as defined in XML Schema |
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. |
boolean |
schemaEquals(Value obj)
Compare two (sequence) values for equality. |
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 |
static java.lang.CharSequence |
trimWhitespace(java.lang.CharSequence in)
Remove leading and trailing whitespace. |
Expression |
typeCheck(StaticContext env,
ItemType contextItemType)
TypeCheck an expression |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface net.sf.saxon.expr.Expression |
getImplementationMethod, iterate |
Field Detail |
public static final java.lang.Class[] EMPTY_CLASS_ARRAY
Constructor Detail |
public Value()
Method Detail |
public 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 converted
XPathException
- 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 information
XPathException
public static double stringToNumber(java.lang.CharSequence s) throws java.lang.NumberFormatException
s
- the String to be converted
java.lang.NumberFormatException
- if the value cannot be convertedpublic static java.lang.CharSequence normalizeWhitespace(java.lang.CharSequence in)
public static java.lang.CharSequence collapseWhitespace(java.lang.CharSequence in)
public static java.lang.CharSequence trimWhitespace(java.lang.CharSequence in)
in
- the input string whose whitespace is to be removed
public static SequenceIterator getIterator(ValueRepresentation val) throws XPathException
XPathException
public final Expression simplify(StaticContext env)
simplify
in interface Expression
public final Expression typeCheck(StaticContext env, ItemType contextItemType)
typeCheck
in interface Expression
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_TYPE
public final Expression optimize(Optimizer opt, StaticContext env, ItemType contextItemType)
optimize
in interface Expression
opt
- 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_TYPE
public ItemType getItemType(TypeHierarchy th)
getItemType
in interface Expression
th
- The TypeHierarchy. Can be null if the target is an AtomicValue.
public int getCardinality()
getCardinality
in interface Expression
StaticProperty.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 Expression
public final Container getParentExpression()
getParentExpression
in interface Expression
public int getSpecialProperties()
StaticProperty.NON_CREATIVE
.
getSpecialProperties
in interface Expression
StaticProperty.NON_CREATIVE
public final Expression promote(PromotionOffer offer)
promote
in interface Expression
offer
- 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 expression
public final int getDependencies()
getDependencies
in interface Expression
public Item itemAt(int n) throws XPathException
XPathException
public int getLength() throws XPathException
XPathException
public Item evaluateItem(XPathContext context) throws XPathException
evaluateItem
in interface Expression
context
- The context in which the expression is to be evaluated
XPathException
- if any dynamic error occurs evaluating the
expressionpublic void process(XPathContext context) throws XPathException
process
in interface Expression
context
- The dynamic context, giving access to the current node,
the current variables, etc.
XPathException
public java.lang.String getStringValue() throws XPathException
getStringValue
in interface ValueRepresentation
XPathException
- 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 Expression
context
- The context in which the expression is to be evaluated
XPathException
- if any dynamic error occurs evaluating the
expression
java.lang.ClassCastException
- if the result type of the
expression is not xs:string?public boolean effectiveBooleanValue(XPathContext context) throws XPathException
effectiveBooleanValue
in interface Expression
context
- The context in which the expression is to be evaluated
XPathException
- if any dynamic error occurs evaluating the
expressionpublic boolean equals(java.lang.Object obj)
public boolean schemaEquals(Value obj)
public int hashCode()
public void checkPermittedContents(SchemaType parentType, StaticContext env, boolean whole) throws XPathException
checkPermittedContents
in interface Expression
parentType
- The schema typeenv
- the static contextwhole
-
XPathException
- if the expression doesn't match the required content typepublic Value reduce() throws XPathException
XPathException
public java.lang.Object convertToJava(java.lang.Class target, XPathContext context) throws XPathException
XPathException
public void display(int level, NamePool pool, java.io.PrintStream out)
display
in interface Expression
level
- indentation level for this expressionpool
- NamePool used to expand any names appearing in the 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 handled
XPathException
public static QNameValue makeQNameValue(java.lang.Object object, Configuration config)
object
- an instance of javax.xml.namespace.QName
public java.lang.String toString()
public static java.lang.Object convert(Item item) throws XPathException
XPathException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |