public class Literal extends Expression
Expression
interface as a wrapper around a GroundedValue
. This may derive from an actual literal in an XPath expression
or query, or it may be the result of evaluating a constant subexpression such as true() or xs:date('2007-01-16')EFFECTIVE_BOOLEAN_VALUE, EVALUATE_METHOD, EVENT_FEED_METHOD, INHERITED_CONTEXT, INSPECTION_CONTEXT, ITEM_FEED_METHOD, ITERATE_METHOD, locationId, MAX_SEQUENCE_LENGTH, MAX_STRING_LENGTH, NAVIGATION_CONTEXT, NODE_VALUE_CONTEXT, PROCESS_METHOD, PUSH_SELECTION, staticProperties, UNBOUNDED_LOWER, UNBOUNDED_UPPER, W3C_CONSUMING, W3C_FREE_RANGING, W3C_GROUP_CONSUMING, W3C_MOTIONLESS, WATCH_METHOD
Modifier | Constructor and Description |
---|---|
protected |
Literal(GroundedValue value)
Create a literal as a wrapper around a Value
|
Modifier and Type | Method and Description |
---|---|
PathMap.PathMapNodeSet |
addToPathMap(PathMap pathMap,
PathMap.PathMapNodeSet pathMapNodeSet)
Add a representation of this expression to a PathMap.
|
int |
computeCardinality()
Determine the cardinality
|
int |
computeSpecialProperties()
Compute the static properties of this expression (other than its type).
|
Expression |
copy()
Copy an expression.
|
boolean |
effectiveBooleanValue(XPathContext context)
Get the effective boolean value of the expression.
|
boolean |
equals(Object obj)
Determine whether two literals are equal, when considered as expressions.
|
CharSequence |
evaluateAsString(XPathContext context)
Evaluate an expression as a String.
|
Item |
evaluateItem(XPathContext context)
Evaluate as a singleton item (or empty sequence).
|
void |
evaluatePendingUpdates(XPathContext context,
PendingUpdateList pul)
Evaluate an updating expression, adding the results to a Pending Update List.
|
void |
explain(ExpressionPresenter out)
Diagnostic print of expression structure.
|
int |
getDependencies()
Determine which aspects of the context the expression depends on.
|
ExpressionCompiler |
getExpressionCompiler()
Return the compiler of the Literal expression
|
IntegerValue[] |
getIntegerBounds()
For an expression that returns an integer or a sequence of integers, get
a lower and upper bound on the values of the integers that may be returned, from
static analysis.
|
ItemType |
getItemType(TypeHierarchy th)
Determine the data type of the items in the expression, if possible
|
int |
getStreamability(int syntacticContext,
boolean allowExtensions,
List<String> reasons)
Get the "sweep" of this expression as defined in the W3C streamability specifications.
|
GroundedValue |
getValue()
Get the value represented by this Literal
|
int |
hashCode()
Return a hash code to support the equals() function
|
static boolean |
isAtomic(Expression exp)
Test whether the literal wraps an atomic value.
|
static boolean |
isConstantBoolean(Expression exp,
boolean value)
Test if a literal represents the boolean value true
|
static boolean |
isConstantOne(Expression exp)
Test if a literal represents the integer value 1
|
static boolean |
isEmptySequence(Expression exp)
Test whether the literal explicitly wraps an empty sequence.
|
boolean |
isSubtreeExpression()
Determine whether the expression can be evaluated without reference to the part of the context
document outside the subtree rooted at the context node.
|
boolean |
isVacuousExpression()
Determine whether this is a vacuous expression as defined in the XQuery update specification
|
SequenceIterator<? extends Item> |
iterate()
Return an Iterator to iterate over the values of a sequence.
|
SequenceIterator<? extends Item> |
iterate(XPathContext context)
Return an Iterator to iterate over the values of a sequence.
|
static Literal |
makeEmptySequence()
Factory method to make an empty-sequence literal
|
static Literal |
makeLiteral(GroundedValue value)
Factory method to create a literal as a wrapper around a Value (factory method)
|
Expression |
optimize(ExpressionVisitor visitor,
ExpressionVisitor.ContextItemType contextItemType)
Optimize an expression
|
void |
process(XPathContext context)
Process the value as an instruction, without returning any tail calls
|
Expression |
simplify(ExpressionVisitor visitor)
Simplify an expression
|
Pattern |
toPattern(Configuration config,
boolean is30)
Convert this expression to an equivalent XSLT pattern
|
Pattern |
toStreamingPattern(Configuration config,
List<String> reasonForFailure)
Convert this expression to a streaming pattern (a pattern used internally to match nodes during
push processing of an event stream)
|
String |
toString()
The toString() method for an expression attempts to give a representation of the expression
in an XPath-like form, but there is no guarantee that the syntax will actually be true XPath.
|
Expression |
typeCheck(ExpressionVisitor visitor,
ExpressionVisitor.ContextItemType contextItemType)
TypeCheck an expression
|
adoptChildExpression, checkForUpdatingSubexpressions, checkPermittedContents, computeDependencies, computeStaticProperties, doPromotion, dynamicError, explain, getCardinality, getColumnNumber, getColumnNumber, getConstructType, getContainer, getEvaluationMethod, getExecutable, getExpressionName, getHostLanguage, getImplementationMethod, getIntrinsicDependencies, getLineNumber, getLineNumber, getLocationId, getLocationProvider, getObjectName, getProperties, getProperty, getPublicId, getSlotsUsed, getSpecialProperties, getStreamingAdjunct, getSystemId, getSystemId, hasVariableBinding, implementsStaticTypeCheck, isUpdatingExpression, iterateEvents, iterateSubExpressionInfo, iterateSubExpressions, markTailFunctionCalls, promote, replaceSubExpression, resetLocalStaticProperties, setContainer, setEvaluationMethod, setFiltered, setFlattened, setLocationId, staticTypeCheck, suppressValidation, typeError
protected Literal(GroundedValue value)
value
- the value of this literalpublic GroundedValue getValue()
public Expression simplify(ExpressionVisitor visitor) throws XPathException
simplify
in class Expression
visitor
- an expression visitorXPathException
- if an error is discovered during expression
rewritingpublic Expression typeCheck(ExpressionVisitor visitor, ExpressionVisitor.ContextItemType contextItemType) throws XPathException
typeCheck
in class Expression
visitor
- an expression visitorcontextItemType
- the static type of "." at the point where this expression is invoked.
The parameter is set to null if it is known statically that the context item will be undefined.
If the type of the context item is not known statically, the argument is set to
Type.ITEM_TYPE
XPathException
- if an error is discovered during this phase
(typically a type error)public Expression optimize(ExpressionVisitor visitor, ExpressionVisitor.ContextItemType contextItemType) throws XPathException
optimize
in class Expression
visitor
- an expression visitorcontextItemType
- the static type of "." at the point where this expression is invoked.
The parameter is set to null if it is known statically that the context item will be undefined.
If the type of the context item is not known statically, the argument is set to
Type.ITEM_TYPE
XPathException
- if an error is discovered during this phase
(typically a type error)public ItemType getItemType(TypeHierarchy th)
getItemType
in class Expression
th
- The TypeHierarchy. Can be null if the target is an AtomicValue.public int computeCardinality()
computeCardinality
in class Expression
StaticProperty.ALLOWS_ZERO_OR_ONE
,
StaticProperty.EXACTLY_ONE
, StaticProperty.ALLOWS_ONE_OR_MORE
,
StaticProperty.ALLOWS_ZERO_OR_MORE
public int computeSpecialProperties()
StaticProperty.NON_CREATIVE
.computeSpecialProperties
in class Expression
StaticProperty.NON_CREATIVE
public IntegerValue[] getIntegerBounds()
getIntegerBounds
in class Expression
public boolean isVacuousExpression()
isVacuousExpression
in class Expression
public Expression copy()
copy
in class Expression
public Pattern toPattern(Configuration config, boolean is30) throws XPathException
toPattern
in class Expression
config
- the Saxon configurationis30
- true if this is XSLT 3.0XPathException
- if conversion is not possiblepublic PathMap.PathMapNodeSet addToPathMap(PathMap pathMap, PathMap.PathMapNodeSet pathMapNodeSet)
addToPathMap
in class Expression
pathMap
- the PathMap to which the expression should be addedpathMapNodeSet
- the set of nodes within the path mappublic final int getDependencies()
getDependencies
in class Expression
public SequenceIterator<? extends Item> iterate(XPathContext context) throws XPathException
iterate
in class Expression
context
- supplies the context for evaluationXPathException
- if any dynamic error occurs evaluating the
expressionpublic SequenceIterator<? extends Item> iterate() throws XPathException
XPathException
- if any dynamic error occurs evaluating the
expressionpublic Item evaluateItem(XPathContext context) throws XPathException
evaluateItem
in class Expression
context
- The context in which the expression is to be evaluatedXPathException
- if any dynamic error occurs evaluating the
expressionpublic void process(XPathContext context) throws XPathException
process
in class Expression
context
- The dynamic context, giving access to the current node,
the current variables, etc.XPathException
- if a dynamic error occurspublic CharSequence evaluateAsString(XPathContext context) throws XPathException
Expression
evaluateAsString
in class Expression
context
- The context in which the expression is to be evaluatedXPathException
- if any dynamic error occurs evaluating the
expressionpublic boolean effectiveBooleanValue(XPathContext context) throws XPathException
effectiveBooleanValue
in class Expression
context
- The context in which the expression is to be evaluatedXPathException
- if any dynamic error occurs evaluating the
expressionpublic void evaluatePendingUpdates(XPathContext context, PendingUpdateList pul) throws XPathException
evaluatePendingUpdates
in class Expression
context
- the XPath dynamic evaluation contextpul
- the pending update list to which the results should be writtenXPathException
- if evaluation failspublic boolean equals(Object obj)
equals
in class Object
obj
- the other expressionpublic int hashCode()
public String toString()
toString
in class Expression
public void explain(ExpressionPresenter out)
explain
in class Expression
out
- the expression presenter used to display the structurepublic static boolean isAtomic(Expression exp)
exp
- an expressionpublic static boolean isEmptySequence(Expression exp)
exp
- an expressionpublic static boolean isConstantBoolean(Expression exp, boolean value)
exp
- an expressionvalue
- true or falsepublic static boolean isConstantOne(Expression exp)
exp
- an expressionpublic boolean isSubtreeExpression()
isSubtreeExpression
in class Expression
public static Literal makeEmptySequence()
public static Literal makeLiteral(GroundedValue value)
value
- the value of this literalpublic Pattern toStreamingPattern(Configuration config, List<String> reasonForFailure)
toStreamingPattern
in class Expression
config
- the Saxon configurationreasonForFailure
- a list which will be populated with messages giving reasons why the
expression cannot be convertedpublic int getStreamability(int syntacticContext, boolean allowExtensions, List<String> reasons)
Expression
getStreamability
in class Expression
syntacticContext
- one of the values Expression.NAVIGATION_CONTEXT
,
Expression.NODE_VALUE_CONTEXT
, Expression.INHERITED_CONTEXT
, Expression.INSPECTION_CONTEXT
allowExtensions
- if false, the definition of "guaranteed streamability" in the
W3C specification is used. If true, Saxon extensions are permitted, which make somereasons
- the caller may supply a list, in which case the implementation may add to this
list a message explaining why the construct is not streamable, suitable for inclusion in an
error message.Expression.W3C_MOTIONLESS
, Expression.W3C_CONSUMING
,
Expression.W3C_GROUP_CONSUMING
, Expression.W3C_FREE_RANGING
public ExpressionCompiler getExpressionCompiler()
getExpressionCompiler
in class Expression
Copyright (c) 2004-2013 Saxonica Limited. All rights reserved.