Class Elaborator
- Direct Known Subclasses:
BooleanElaborator
,FallbackElaborator
,ItemElaborator
,PullElaborator
,PushElaborator
,SimpleNodePushElaborator
,StringElaborator
,UpdateElaborator
This mechanism evaluates expressions in two stages. The first stage (the elaboration stage), converts the expression to a lambda function, specifically a function of the context that can be called to produce the expression result. The second stage invokes this function (supplying the context as an argument) to generate the result.
The mechanism is complicated by the fact that expressions can be evaluated in different modes.
Specifically: pull evaluation delivers an iterator over the result, item evaluation delivers
the singleton result as an item; push evaluation sends the results to an Outputter
,
boolean evaluation returns the effective boolean value, and string evaluation returns the
string value. Update evaluation is used for XQuery update expressions.
The Elaborator
class is the abstract root of a hierarchy of classes for elaborating
different kinds of expression.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioneagerly()
Get a function that evaluates the underlying expression eagerlyabstract BooleanEvaluator
Get a function that evaluates the underlying expression in the form of a boolean, this being the effective boolean value of the expression.abstract ItemEvaluator
Get a function that evaluates the underlying expression in the form of aItem
.abstract PullEvaluator
Get a function that evaluates the underlying expression in the form of aSequenceIterator
abstract PushEvaluator
Get a function that evaluates the underlying expression in push mode, by writing events to anOutputter
elaborateForString
(boolean zeroLengthWhenAbsent) Get a function that evaluates the underlying expression in the form of a Java string, this being the result of applying fn:string() to the result of the expression.abstract UnicodeStringEvaluator
elaborateForUnicodeString
(boolean zeroLengthWhenAbsent) Get a function that evaluates the underlying expression in the form of a unicode string, this being the result of applying fn:string() to the result of the expression.protected Configuration
Get the Saxon ConfigurationGet the expression being elaboratedprotected final String
handleNullString
(boolean zeroLengthWhenAbsent) Helper method that returns either a zero length string or null, depending on the parameterprotected final UnicodeString
handleNullUnicodeString
(boolean zeroLengthWhenAbsent) Helper method that returns either a zero length string or null, depending on the parameterprotected final String
handlePossiblyNullString
(String str, boolean zeroLengthWhenAbsent) protected final UnicodeString
handlePossiblyNullUnicodeString
(UnicodeString str, boolean zeroLengthWhenAbsent) lazily
(boolean repeatable, boolean lazyEvaluationRequired) Get a function that evaluates the underlying expression lazilyvoid
setExpression
(Expression expr) Set the expression being elaborated
-
Constructor Details
-
Elaborator
public Elaborator()
-
-
Method Details
-
getExpression
Get the expression being elaborated- Returns:
- the expression
-
setExpression
Set the expression being elaborated- Parameters:
expr
- the expression
-
getConfiguration
Get the Saxon Configuration- Returns:
- the Configuration
-
eagerly
Get a function that evaluates the underlying expression eagerly- Returns:
- an evaluator for the expression that returns a
GroundedValue
. The classSequenceEvaluator
is declared to return aSequence
not aGroundedValue
; we can't specialize it because it's a limitation of C# delegates, but the result can safely be cast toGroundedValue
.
-
lazily
Get a function that evaluates the underlying expression lazily- Parameters:
repeatable
- true if the resultingSequence
must be usable repeatedly; false if it only needs to be used oncelazyEvaluationRequired
- true if the expression MUST be evaluated lazily, for example to prevent spurious errors or side-effects if it has been lifted out of a loop- Returns:
- an evaluator for the expression that returns a
Sequence
(which may be a lazy sequence)
-
elaborateForPull
Get a function that evaluates the underlying expression in the form of aSequenceIterator
- Returns:
- an evaluator for the expression that returns a
SequenceIterator
-
elaborateForPush
Get a function that evaluates the underlying expression in push mode, by writing events to anOutputter
- Returns:
- an evaluator for the expression in push mode
-
elaborateForItem
Get a function that evaluates the underlying expression in the form of aItem
. This must only be called for expressions whose result has cardinality zero or one.- Returns:
- an evaluator for the expression that returns an
Item
, or null to represent an empty sequence.
-
elaborateForBoolean
Get a function that evaluates the underlying expression in the form of a boolean, this being the effective boolean value of the expression.- Returns:
- an evaluator for the expression that returns a boolean.
-
elaborateForUnicodeString
Get a function that evaluates the underlying expression in the form of a unicode string, this being the result of applying fn:string() to the result of the expression.- Parameters:
zeroLengthWhenAbsent
- if true, then when the result of the expression is an empty sequence, the result of the StringEvaluator should be a zero-length string. If false, the return value should be null. For an expression or function that never returns an empty sequence (for example, a call on string() or normalize-space()), the argument has no effect.- Returns:
- an evaluator for the expression that returns a string.
-
elaborateForString
Get a function that evaluates the underlying expression in the form of a Java string, this being the result of applying fn:string() to the result of the expression.- Parameters:
zeroLengthWhenAbsent
- if true, then when the result of the expression is an empty sequence, the result of the StringEvaluator should be a zero-length string. If false, the return value should be null.- Returns:
- an evaluator for the expression that returns a string.
-
handleNullUnicodeString
Helper method that returns either a zero length string or null, depending on the parameter- Parameters:
zeroLengthWhenAbsent
- if true, return a zero length string; if false, return null
-
handlePossiblyNullUnicodeString
protected final UnicodeString handlePossiblyNullUnicodeString(UnicodeString str, boolean zeroLengthWhenAbsent) -
handleNullString
Helper method that returns either a zero length string or null, depending on the parameter- Parameters:
zeroLengthWhenAbsent
- if true, return a zero length string; if false, return null
-
handlePossiblyNullString
-
elaborateForUpdate
-