Package net.sf.saxon.value
Class SingletonNode
java.lang.Object
net.sf.saxon.value.Value
net.sf.saxon.value.SingletonNode
- All Implemented Interfaces:
Serializable
,Expression
,ValueRepresentation
A value that is a sequence containing zero or one nodes
- See Also:
-
Field Summary
FieldsFields inherited from class net.sf.saxon.value.Value
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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionconvertToJava
(Class target, XPathContext context) Convert to Java object (for passing to external functions)void
display
(int depth, PrintStream out, Configuration config) Diagnostic displayboolean
effectiveBooleanValue
(XPathContext context) Get the effective boolean valueevaluateAsString
(XPathContext context) Evaluate an expression as a String.evaluateItem
(XPathContext context) Evaluate as an itemint
Determine the static cardinalityint
An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process().Determine the data type of the items in the expression.int
Get the length of the sequencegetNode()
Get the node that forms the node-set.int
Get the static properties of this expression (other than its type).Convert the value to a string, using the serialization rules.itemAt
(int n) Get the n'th item in the sequence (starting from 0).iterate
(XPathContext context) Return an enumeration of this nodeset value.void
process
(XPathContext context) Process the instruction, without returning any tail callsMethods inherited from class net.sf.saxon.value.Value
asItem, asIterator, asValue, checkPermittedContents, convert, convertJavaObjectToXPath, equals, getDependencies, getIterator, getParentExpression, getStringValueCS, hashCode, iterateSubExpressions, makeQNameValue, optimize, promote, reduce, simplify, stringToNumber, toString, typeCheck
-
Field Details
-
node
-
-
Constructor Details
-
SingletonNode
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 Details
-
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. -
process
Process the instruction, without returning any tail calls- Specified by:
process
in interfaceExpression
- Overrides:
process
in classValue
- Parameters:
context
- The dynamic context, giving access to the current node, the current variables, etc.- Throws:
XPathException
-
getItemType
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.- Specified by:
getItemType
in interfaceExpression
- Overrides:
getItemType
in classValue
- Parameters:
th
-- Returns:
- the most precise possible type of the node.
-
getCardinality
public int getCardinality()Determine the static cardinality- Specified by:
getCardinality
in interfaceExpression
- Overrides:
getCardinality
in classValue
- Returns:
- one of the values
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).
-
getLength
Get the length of the sequence- Overrides:
getLength
in classValue
- Throws:
XPathException
-
itemAt
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)- Overrides:
itemAt
in classValue
- Throws:
XPathException
-
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.- Specified by:
getSpecialProperties
in interfaceExpression
- Overrides:
getSpecialProperties
in classValue
- Returns:
StaticProperty.NON_CREATIVE
-
iterate
Return an enumeration of this nodeset value.- Parameters:
context
- 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)- Returns:
- a SequenceIterator that can be used to iterate over the result of the expression
-
evaluateItem
Evaluate as an item- Specified by:
evaluateItem
in interfaceExpression
- Overrides:
evaluateItem
in classValue
- Parameters:
context
- 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)- Returns:
- the node or atomic value that results from evaluating the expression; or null to indicate that the result is an empty sequence
-
effectiveBooleanValue
Get the effective boolean value- Specified by:
effectiveBooleanValue
in interfaceExpression
- Overrides:
effectiveBooleanValue
in classValue
- Parameters:
context
- The context in which the expression is to be evaluated- Returns:
- the effective boolean value
-
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.- Specified by:
getStringValue
in interfaceValueRepresentation
- Overrides:
getStringValue
in classValue
-
evaluateAsString
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.- Specified by:
evaluateAsString
in interfaceExpression
- Overrides:
evaluateAsString
in classValue
- 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
-
display
Diagnostic display- Specified by:
display
in interfaceExpression
- Overrides:
display
in classValue
- Parameters:
depth
- indentation level for this expressionout
- Output destinationconfig
-
-
convertToJava
Convert to Java object (for passing to external functions)- Overrides:
convertToJava
in classValue
- Throws:
XPathException
-