| java.lang.Object net.sf.saxon.value.Value
All known Subclasses: net.sf.saxon.value.IntegerRange, net.sf.saxon.value.Closure, net.sf.saxon.value.ShareableSequence, net.sf.saxon.value.AtomicValue, net.sf.saxon.value.SingletonNode, net.sf.saxon.value.SequenceExtent, net.sf.saxon.value.EmptySequence,
Value | abstract public class Value implements Expression,Serializable,ValueRepresentation(Code) | | 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.
|
Method Summary | |
public static Item | asItem(ValueRepresentation value, XPathContext context) Static method to make an Item from a Value
Parameters: value - the value to be converted Parameters: context - the context. | public 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
Parameters: val - The supplied value, or null, indicating the empty sequence. Parameters: context - The evaluation context. | public static Value | asValue(ValueRepresentation val) Static method to make a Value from a given Item (which may be either an AtomicValue
or a NodeInfo
Parameters: val - The supplied value, or null, indicating the empty sequence. | public 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. | public static CharSequence | collapseWhitespace(CharSequence in) | public static Object | convert(Item item) Internal method to convert an XPath value to a Java object.
An atomic value is returned as an instance
of the best available Java class. | public static Value | convertJavaObjectToXPath(Object object, SequenceType requiredType, Configuration config) Convert a Java object to an XPath value. | public Object | convertToJava(Class target, XPathContext context) | public void | display(int level, NamePool pool, PrintStream out) | public boolean | effectiveBooleanValue(XPathContext context) Get the effective boolean value of the expression. | public boolean | equals(Object obj) Compare two (sequence) values for equality. | public String | evaluateAsString(XPathContext context) Evaluate an expression as a String. | public Item | evaluateItem(XPathContext context) Evaluate as a singleton item (or empty sequence). | public int | getCardinality() | final public int | getDependencies() Determine which aspects of the context the expression depends on. | public ItemType | getItemType(TypeHierarchy th) Determine the data type of the items in the expression, if possible
for the default implementation: AnyItemType (not known) Parameters: th - The TypeHierarchy. | public static SequenceIterator | getIterator(ValueRepresentation val) | public int | getLength() | final public Container | getParentExpression() Get the expression that immediately contains this expression. | public int | getSpecialProperties() Get the static properties of this expression (other than its type). | public String | getStringValue() Convert the value to a string, using the serialization rules. | public int | hashCode() | public Item | itemAt(int n) Get the n'th item in the sequence (starting from 0). | final public Iterator | iterateSubExpressions() Get the sub-expressions of this expression. | public static QNameValue | makeQNameValue(Object object, Configuration config) | public static CharSequence | normalizeWhitespace(CharSequence in) | final public Expression | optimize(Optimizer opt, StaticContext env, ItemType contextItemType) | public void | process(XPathContext context) | final public Expression | promote(PromotionOffer offer) Offer promotion for this subexpression. | public Value | reduce() Reduce a value to its simplest form. | public boolean | schemaEquals(Value obj) Compare two (sequence) values for equality. | final public Expression | simplify(StaticContext env) | public static double | stringToNumber(CharSequence s) Static method to convert strings to numbers. | public String | toString() | public static CharSequence | trimWhitespace(CharSequence in) Remove leading and trailing whitespace. | final public Expression | typeCheck(StaticContext env, ItemType contextItemType) |
EMPTY_CLASS_ARRAY | final public static Class[] EMPTY_CLASS_ARRAY(Code) | | |
asItem | public static Item asItem(ValueRepresentation value, XPathContext context) throws XPathException(Code) | | Static method to make an Item from a Value
Parameters: value - the value to be converted Parameters: context - the context. It is probably safe to set this to null. null if the value is an empty sequence; or the only item in the valueif it is a singleton sequence throws: XPathException - if the Value contains multiple items |
asIterator | public static SequenceIterator asIterator(ValueRepresentation val, XPathContext context) throws XPathException(Code) | | Static method to get an Iterator over any ValueRepresentation (which may be either a Value
or a NodeInfo
Parameters: val - The supplied value, or null, indicating the empty sequence. Parameters: context - The evaluation context. This may be null. It should always be possible toiterate over a value without supplying a context, but sometimes the contextcan provide access to better error information The supplied value, if it is a value, or a SingletonNode thatwraps the item, if it is a node. If the supplied value was null,return an EmptySequence |
asValue | public static Value asValue(ValueRepresentation val)(Code) | | Static method to make a Value from a given Item (which may be either an AtomicValue
or a NodeInfo
Parameters: val - The supplied value, or null, indicating the empty sequence. The supplied value, if it is a value, or a SingletonNode thatwraps the item, if it is a node. If the supplied value was null,return an EmptySequence |
checkPermittedContents | public void checkPermittedContents(SchemaType parentType, StaticContext env, boolean whole) throws XPathException(Code) | | Check statically that the results of the expression are capable of constructing the content
of a given schema type.
Parameters: parentType - The schema type Parameters: env - the static context Parameters: whole - throws: XPathException - if the expression doesn't match the required content type |
convert | public static Object convert(Item item) throws XPathException(Code) | | Internal method to convert an XPath value to a Java object.
An atomic value is returned as an instance
of the best available Java class. If the item is a node, the node is "unwrapped",
to return the underlying node in the original model (which might be, for example,
a DOM or JDOM node).
|
convertJavaObjectToXPath | public static Value convertJavaObjectToXPath(Object object, SequenceType requiredType, Configuration config) throws XPathException(Code) | | Convert a Java object to an XPath value. This method is called to handle the result
of an external function call (but only if the required type is not known),
and also to process global parameters passed to the stylesheet or query.
Parameters: object - The Java object to be converted Parameters: requiredType - The required type of the result (if known) Parameters: config - The Configuration: may be null, in which case certain kinds of object(eg. DOM nodes) cannot be handled the result of converting the value. If the value is null, returns null. |
effectiveBooleanValue | public boolean effectiveBooleanValue(XPathContext context) throws XPathException(Code) | | Get the effective boolean value of the expression. This returns false if the value
is the empty sequence, a zero-length string, a number equal to zero, or the boolean
false. Otherwise it returns true.
Parameters: context - The context in which the expression is to be evaluated exception: XPathException - if any dynamic error occurs evaluating theexpression the effective boolean value |
equals | public boolean equals(Object obj)(Code) | | Compare two (sequence) values for equality. This supports identity constraints in XML Schema,
which allow list-valued elements and attributes to participate in key and uniqueness constraints.
This method returns false if any error occurs during the comparison, or if any of the items
in either sequence is a node rather than an atomic value.
|
evaluateAsString | public String evaluateAsString(XPathContext context) throws XPathException(Code) | | Evaluate an expression as a String. This function must only be called in contexts
where it is known that the expression will return a single string (or where an empty sequence
is to be treated as a zero-length string). Implementations should not attempt to convert
the result to a string, other than converting () to "". This method is used mainly to
evaluate expressions produced by compiling an attribute value template.
exception: XPathException - if any dynamic error occurs evaluating theexpression exception: ClassCastException - if the result type of theexpression is not xs:string? Parameters: context - The context in which the expression is to be evaluated the value of the expression, evaluated in the current context.The expression must return a string or (); if the value of theexpression is (), this method returns "". |
evaluateItem | public Item evaluateItem(XPathContext context) throws XPathException(Code) | | Evaluate as a singleton item (or empty sequence). Note: this implementation returns
the first item in the sequence. The method should not be used unless appropriate type-checking
has been done to ensure that the value will be a singleton.
|
getCardinality | public int getCardinality()(Code) | | Determine the cardinality
|
getDependencies | final public int getDependencies()(Code) | | Determine which aspects of the context the expression depends on. The result is
a bitwise-or'ed value composed from constants such as StaticProperty.VARIABLES and
StaticProperty.CURRENT_NODE
for a Value, this always returns zero. |
getItemType | public ItemType getItemType(TypeHierarchy th)(Code) | | Determine the data type of the items in the expression, if possible
for the default implementation: AnyItemType (not known) Parameters: th - The TypeHierarchy. Can be null if the target is an AtomicValue. |
getParentExpression | final public Container getParentExpression()(Code) | | Get the expression that immediately contains this expression. This method
returns null for an outermost expression; it also return null in the case
of literal values. For an XPath expression occurring within an XSLT stylesheet,
this method returns the XSLT instruction containing the XPath expression.
the expression that contains this expression, if known; return nullif there is no containing expression or if the containing expression is unknown. |
getStringValue | public String getStringValue() throws XPathException(Code) | | Convert the value to a string, using the serialization rules.
For atomic values this is the same as a cast; for sequence values
it gives a space-separated list.
throws: XPathException - The method can fail if evaluation of the valuehas been deferred, and if a failure occurs during the deferred evaluation.No failure is possible in the case of an AtomicValue. |
hashCode | public int hashCode()(Code) | | Return a hash code to support the equals() function
|
itemAt | public Item itemAt(int n) throws XPathException(Code) | | Get the n'th item in the sequence (starting from 0). This is defined for all
Values, but its real benefits come for a sequence Value stored extensionally
(or for a MemoClosure, once all the values have been read)
|
iterateSubExpressions | final public Iterator iterateSubExpressions()(Code) | | Get the sub-expressions of this expression.
for a Value, this always returns an empty array |
makeQNameValue | public static QNameValue makeQNameValue(Object object, Configuration config)(Code) | | 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
Parameters: object - an instance of javax.xml.namespace.QName a corresponding Saxon QNameValue, or null if any error occurs performing the conversion |
process | public void process(XPathContext context) throws XPathException(Code) | | Process the value as an instruction, without returning any tail calls
Parameters: context - The dynamic context, giving access to the current node,the current variables, etc. |
promote | final public Expression promote(PromotionOffer offer)(Code) | | Offer promotion for this subexpression. Values (constant expressions)
are never promoted
Parameters: offer - details of the offer, for example the offer to moveexpressions that don't depend on the context to an outer level inthe containing expression For a Value, this always returns the value unchanged |
reduce | public Value reduce() throws XPathException(Code) | | Reduce a value to its simplest form. If the value is a closure or some other form of deferred value
such as a FunctionCallPackage, then it is reduced to a SequenceExtent. If it is a SequenceExtent containing
a single item, then it is reduced to that item. One consequence that is exploited by class FilterExpression
is that if the value is a singleton numeric value, then the result will be an instance of NumericValue
|
schemaEquals | public boolean schemaEquals(Value obj)(Code) | | Compare two (sequence) values for equality. This supports identity constraints in XML Schema,
which allow list-valued elements and attributes to participate in key and uniqueness constraints.
This method returns false if any error occurs during the comparison, or if any of the items
in either sequence is a node rather than an atomic value.
|
stringToNumber | public static double stringToNumber(CharSequence s) throws NumberFormatException(Code) | | Static method to convert strings to numbers. Might as well go here as anywhere else.
Parameters: s - the String to be converted a double representing the value of the String throws: NumberFormatException - if the value cannot be converted |
toString | public String toString()(Code) | | Convert to a string for diagnostic output
|
trimWhitespace | public static CharSequence trimWhitespace(CharSequence in)(Code) | | Remove leading and trailing whitespace. This has the same effect as collapseWhitespace,
but is cheaper, for use by data types that do not allow internal whitespace.
Parameters: in - the input string whose whitespace is to be removed the result of removing excess whitespace |
|
|