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, ITEM_FEED_METHOD, ITERATE_METHOD, MAX_SEQUENCE_LENGTH, MAX_STRING_LENGTH, PROCESS_METHOD, staticProperties, UNBOUNDED_LOWER, UNBOUNDED_UPPER, UPDATE_METHOD, 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 |
export(ExpressionPresenter out)
Diagnostic print of expression structure.
|
static void |
exportAtomicValue(AtomicValue value,
ExpressionPresenter out) |
static void |
exportValue(Sequence value,
ExpressionPresenter out) |
int |
getCost()
Return the estimated cost of evaluating an expression.
|
int |
getDependencies()
Determine which aspects of the context the expression depends on.
|
ExpressionCompiler |
getExpressionCompiler()
Return the compiler of the Literal expression
|
int |
getImplementationMethod()
An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process().
|
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()
Determine the data type of the items in the expression, if possible
|
protected StreamingAdjunct |
getStreamingAdjunct()
Get an object that supports streamed evaluation of this expression
|
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 |
iterate()
Return an Iterator to iterate over the values of a sequence.
|
SequenceIterator |
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)
|
static Literal |
makeStringsLiteral(List<String> strings)
Create a Literal containing a sequence of strings
|
Expression |
optimize(ExpressionVisitor visitor,
ContextItemStaticInfo contextItemType)
Optimize an expression
|
void |
process(XPathContext context)
Process the value as an instruction, without returning any tail calls
|
Expression |
promote(PromotionOffer offer)
Offer promotion for this subexpression.
|
Pattern |
toPattern(Configuration config,
boolean is30)
Convert this expression to an equivalent XSLT pattern
|
String |
toShortString()
Produce a short string identifying the expression for use in error messages
|
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,
ContextItemStaticInfo contextInfo)
TypeCheck an expression
|
adoptChildExpression, checkedOperands, checkForUpdatingSubexpressions, checkPermittedContents, clearStreamabilityData, computeDependencies, computeStaticProperties, doPromotion, dynamicError, explain, getCardinality, getConfiguration, getConstructType, getEvaluationMethod, getExpressionName, getHostLanguage, getIntrinsicDependencies, getLocation, getNetCost, getObjectName, getPackageData, getParentExpression, getPosture, getPostureAndSweepIfKnown, getProperties, getProperty, getRetainedStaticContext, getSlotsUsed, getSpecialProperties, getStaticBaseURI, getStaticBaseURIString, getStreamability, getSweep, getSystemId, hasVariableBinding, identityHashCode, implementsStaticTypeCheck, isCallOn, isCallOnSystemFunction, isIdentical, isUpdatingExpression, iterateEvents, makeStreamingAdjunct, markTailFunctionCalls, operandList, operands, operandSparseList, optimizeChildren, optimizeForType, promoteChildren, resetLocalStaticProperties, restoreParentPointers, setEvaluationMethod, setFiltered, setFlattened, setLocation, setParentExpression, setPostureAndSweep, setRetainedStaticContext, setRetainedStaticContextLocally, setStaticProperty, simplify, simplifyChildren, staticTypeCheck, suppressValidation, toStreamingPattern, typeCheckChildren, typeError, unordered
protected Literal(GroundedValue value)
value
- the value of this literalpublic static Literal makeStringsLiteral(List<String> strings)
strings
- the strings to be wrappedpublic GroundedValue getValue()
public Expression typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException
typeCheck
in class Expression
visitor
- an expression visitorcontextInfo
- Information available statically about the context item: whether it is (possibly)
absent; its static type; its streaming posture.XPathException
- if an error is discovered during this phase
(typically a type error)public Expression optimize(ExpressionVisitor visitor, ContextItemStaticInfo 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 int getCost()
getCost
in class Expression
public ItemType getItemType()
getItemType
in class Expression
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 promote(PromotionOffer offer) throws XPathException
promote
in class Expression
offer
- details of the offer, for example the offer to move
expressions that don't depend on the context to an outer level in
the containing expressionXPathException
- if any error is detectedpublic 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 iterate(XPathContext context) throws XPathException
iterate
in class Expression
context
- supplies the context for evaluationXPathException
- if any dynamic error occurs evaluating the
expressionpublic SequenceIterator 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 int getImplementationMethod()
Expression
getImplementationMethod
in class Expression
Expression.ITERATE_METHOD
or Expression.EVALUATE_METHOD
or
Expression.PROCESS_METHOD
public 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 export(ExpressionPresenter out)
export
in class Expression
out
- the expression presenter used to display the structurepublic static void exportValue(Sequence value, ExpressionPresenter out)
public static void exportAtomicValue(AtomicValue value, ExpressionPresenter out)
public String toShortString()
toShortString
in class Expression
public 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 literalprotected StreamingAdjunct getStreamingAdjunct()
Expression
getStreamingAdjunct
in class Expression
public ExpressionCompiler getExpressionCompiler()
getExpressionCompiler
in class Expression
Copyright (c) 2004-2014 Saxonica Limited. All rights reserved.