net.sf.saxon.value

Class SingletonNode

public class SingletonNode extends Value

A value that is a sequence containing zero or one nodes
Field Summary
protected NodeInfonode
Constructor Summary
SingletonNode(NodeInfo node)
Create a node-set containing zero or one nodes
Method Summary
ObjectconvertToJava(Class target, XPathContext context)
Convert to Java object (for passing to external functions)
voiddisplay(int depth, NamePool pool, PrintStream out)
Diagnostic display
booleaneffectiveBooleanValue(XPathContext context)
Get the effective boolean value
StringevaluateAsString(XPathContext context)
Evaluate an expression as a String.
ItemevaluateItem(XPathContext context)
Evaluate as an item
intgetCardinality()
Determine the static cardinality
intgetImplementationMethod()
An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process().
ItemTypegetItemType(TypeHierarchy th)
Determine the data type of the items in the expression.
intgetLength()
Get the length of the sequence
NodeInfogetNode()
Get the node that forms the node-set.
intgetSpecialProperties()
Get the static properties of this expression (other than its type).
StringgetStringValue()
Convert the value to a string, using the serialization rules.
ItemitemAt(int n)
Get the n'th item in the sequence (starting from 0).
SequenceIteratoriterate(XPathContext context)
Return an enumeration of this nodeset value.
voidprocess(XPathContext context)
Process the instruction, without returning any tail calls

Field Detail

node

protected NodeInfo node

Constructor Detail

SingletonNode

public SingletonNode(NodeInfo node)
Create a node-set containing zero or one nodes

Parameters: node The node to be contained in the node-set, or null if the node-set is to be empty

Method Detail

convertToJava

public Object convertToJava(Class target, XPathContext context)
Convert to Java object (for passing to external functions)

display

public void display(int depth, NamePool pool, PrintStream out)
Diagnostic display

effectiveBooleanValue

public boolean effectiveBooleanValue(XPathContext context)
Get the effective boolean value

evaluateAsString

public String evaluateAsString(XPathContext context)
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

evaluateItem

public Item evaluateItem(XPathContext context)
Evaluate as an item

getCardinality

public int getCardinality()
Determine the static cardinality

getImplementationMethod

public int getImplementationMethod()
An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process(). This method indicates which of these methods is prefered.

getItemType

public ItemType getItemType(TypeHierarchy th)
Determine the data type of the items in the expression. This method determines the most precise type that it can, because it is called when testing that the node conforms to a required type.

Parameters: th

Returns: the most precise possible type of the node.

getLength

public int getLength()
Get the length of the sequence

getNode

public NodeInfo getNode()
Get the node that forms the node-set. Return null if there is none.

getSpecialProperties

public int getSpecialProperties()
Get the static properties of this expression (other than its type). The result is bit-signficant. These properties are used for optimizations. In general, if property bit is set, it is true, but if it is unset, the value is unknown.

getStringValue

public String getStringValue()
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. For QNames and NOTATIONS, or lists containing them, it fails.

itemAt

public Item itemAt(int n)
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 (or for a MemoClosure, once all the values have been read)

iterate

public SequenceIterator iterate(XPathContext context)
Return an enumeration of this nodeset value.

process

public void process(XPathContext context)
Process the instruction, without returning any tail calls

Parameters: context The dynamic context, giving access to the current node, the current variables, etc.