net.sf.saxon.value
Class SequenceValue

java.lang.Object
  extended bynet.sf.saxon.value.Value
      extended bynet.sf.saxon.value.SequenceValue
All Implemented Interfaces:
Expression, java.io.Serializable
Direct Known Subclasses:
Closure, EmptySequence, SequenceExtent, SequenceIntent

public abstract class SequenceValue
extends Value

A SequenceValue object represents a sequence whose members are all AtomicValues or Nodes.

See Also:
Serialized Form

Constructor Summary
SequenceValue()
           
 
Method Summary
 int conversionPreference(java.lang.Class required)
          Get conversion preference for this value to a Java class.
 java.lang.Object convertToJava(java.lang.Class target)
          Convert to Java object (for passing to external functions)
 void display(int level, NamePool pool)
          Diagnostic display of the expression
 boolean effectiveBooleanValue(XPathContext context)
          Get the effective boolean value of the expression.
 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
 ItemType getItemType()
          Determine the data type of the items in the expression, if possible
 Item itemAt(int n)
          Get the n'th item in the sequence (starting from 0).
static int nodeToJavaPreference(NodeInfo node, java.lang.Class required)
           
 
Methods inherited from class net.sf.saxon.value.Value
analyze, asItem, asValue, collapseWhitespace, getDependencies, getSpecialProperties, getSubExpressions, inverse, normalizeWhitespace, promote, simplify, stringToInteger, stringToNumber, trimWhitespace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.saxon.expr.Expression
iterate
 

Constructor Detail

SequenceValue

public SequenceValue()
Method Detail

getItemType

public ItemType getItemType()
Determine the data type of the items in the expression, if possible

Returns:
AnyItemType (not known)

getCardinality

public int getCardinality()
Determine the cardinality

Returns:
one of the values Cardinality.ONE_OR_MORE, Cardinality.ZERO_OR_MORE, Cardinality.EXACTLY_ONE, Cardinality.ZERO_OR_ONE, Cardinality.EMPTY. This default implementation returns ZERO_OR_MORE (which effectively gives no information).

itemAt

public Item itemAt(int n)
            throws XPathException
Get the n'th item in the sequence (starting from 0). This is defined for all SequenceValues, but its real benefits come for a SequenceValue stored extensionally

Throws:
XPathException

evaluateItem

public Item evaluateItem(XPathContext context)
                  throws XPathException
Evaluate as a singleton item (or empty sequence)

Parameters:
context - The context in which the expression is to be evaluated
Returns:
the node or atomic value that results from evaluating the expression; or null to indicate that the result is an empty sequence
Throws:
XPathException - if any dynamic error occurs evaluating the expression

evaluateAsString

public java.lang.String evaluateAsString(XPathContext context)
                                  throws XPathException
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.

Parameters:
context - The context in which the expression is to be evaluated
Returns:
the value of the expression, evaluated in the current context. The expression must return a string or (); if the value of the expression is (), this method returns "".
Throws:
XPathException - if any dynamic error occurs evaluating the expression
java.lang.ClassCastException - if the result type of the expression is not xs:string?

effectiveBooleanValue

public boolean effectiveBooleanValue(XPathContext context)
                              throws XPathException
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
Returns:
the effective boolean value
Throws:
XPathException - if any dynamic error occurs evaluating the expression

conversionPreference

public int conversionPreference(java.lang.Class required)
Get conversion preference for this value to a Java class. A low result indicates higher preference.

Specified by:
conversionPreference in class Value

nodeToJavaPreference

public static int nodeToJavaPreference(NodeInfo node,
                                       java.lang.Class required)

convertToJava

public java.lang.Object convertToJava(java.lang.Class target)
                               throws XPathException
Convert to Java object (for passing to external functions)

Specified by:
convertToJava in class Value
Parameters:
target - The class required by the external function
Returns:
an object of the target class
Throws:
XPathException

display

public void display(int level,
                    NamePool pool)
Diagnostic display of the expression

Parameters:
level - indentation level for this expression