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_COST, 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 |
computeHashCode()
Return a hash code to support the equals() function
|
int |
computeSpecialProperties()
Compute the static properties of this expression (other than its type).
|
Expression |
copy(RebindingMap rebindings)
Copy an expression.
|
boolean |
effectiveBooleanValue(XPathContext context)
Get the effective boolean value of the expression.
|
boolean |
equals(java.lang.Object obj)
Determine whether two literals are equal, when considered as expressions.
|
java.lang.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 |
getDependencies()
Determine which aspects of the context the expression depends on.
|
java.lang.String |
getExpressionName()
Get a name identifying the kind of expression, in terms meaningful to a user.
|
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
|
int |
getNetCost()
Return the estimated cost of evaluating an expression.
|
UType |
getStaticUType(UType contextItemType)
Get the static type of the expression as a UType, following precisely the type
inference rules defined in the XSLT 3.0 specification.
|
java.lang.String |
getStreamerName()
Get the (partial) name of a class that supports streaming of this kind of expression
|
GroundedValue<?> |
getValue()
Get the value represented by this Literal
|
static boolean |
hasEffectiveBooleanValue(Expression exp,
boolean value)
Test if a literal has the effective boolean value true (or false)
|
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,
Expression origin)
Make a literal, taking the retained static context and location information from another
expression which is being simplified/optimized
|
static <T extends Item<?>> |
makeLiteral(GroundedValue<T> value)
Factory method to create a literal as a wrapper around a Value (factory method)
|
static Literal |
makeStringsLiteral(java.util.List<java.lang.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
|
Pattern |
toPattern(Configuration config)
Convert this expression to an equivalent XSLT pattern
|
java.lang.String |
toShortString()
Produce a short string identifying the expression for use in error messages
|
java.lang.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, allowExtractingCommonSubexpressions, checkedOperands, checkForUpdatingSubexpressions, checkPermittedContents, computeDependencies, computeStaticProperties, dynamicError, explain, getCardinality, getConfiguration, getConstructType, getCost, getEvaluationMethod, getExtraProperty, getInterpretedExpression, getIntrinsicDependencies, getLocalRetainedStaticContext, getLocation, getObjectName, getPackageData, getParentExpression, getProperties, getProperty, getRetainedStaticContext, getScopingExpression, getSlotsUsed, getSpecialProperties, getStaticBaseURI, getStaticBaseURIString, getStaticType, hasCompatibleStaticContext, hashCode, hasSpecialProperty, hasVariableBinding, identityHashCode, implementsStaticTypeCheck, isCallOn, isEqual, isIdentical, isInstruction, isLiftable, isMultiThreaded, isStaticPropertiesKnown, isUpdatingExpression, markTailFunctionCalls, operandList, operands, operandSparseList, optimizeChildren, prepareForStreaming, resetLocalStaticProperties, restoreParentPointers, setEvaluationMethod, setExtraProperty, setFiltered, setFlattened, setLocation, setParentExpression, setRetainedStaticContext, setRetainedStaticContextLocally, setRetainedStaticContextThoroughly, setStaticProperty, simplify, simplifyChildren, staticTypeCheck, suppressValidation, typeCheckChildren, typeError, unordered, verifyParentPointersprotected Literal(GroundedValue<?> value)
value - the value of this literalpublic static Literal makeStringsLiteral(java.util.List<java.lang.String> strings)
strings - the strings to be wrappedpublic GroundedValue<?> getValue()
public Expression typeCheck(ExpressionVisitor visitor, ContextItemStaticInfo contextInfo) throws XPathException
typeCheck in class Expressionvisitor - 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 Expressionvisitor - 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_TYPEXPathException - if an error is discovered during this phase
(typically a type error)public int getNetCost()
getNetCost in class Expressionpublic ItemType getItemType()
getItemType in class Expressionpublic UType getStaticUType(UType contextItemType)
getStaticUType in class ExpressioncontextItemType - the static context item typepublic int computeCardinality()
computeCardinality in class ExpressionStaticProperty.ALLOWS_ZERO_OR_ONE,
StaticProperty.EXACTLY_ONE, StaticProperty.ALLOWS_ONE_OR_MORE,
StaticProperty.ALLOWS_ZERO_OR_MORE. May also return StaticProperty.ALLOWS_ZERO if
the result is known to be an empty sequence, or StaticProperty.ALLOWS_MANY if
if is known to return a sequence of length two or more.public int computeSpecialProperties()
StaticProperty.NO_NODES_NEWLY_CREATED.computeSpecialProperties in class ExpressionStaticProperty.NO_NODES_NEWLY_CREATEDpublic IntegerValue[] getIntegerBounds()
getIntegerBounds in class Expressionpublic boolean isVacuousExpression()
isVacuousExpression in class Expressionpublic Expression copy(RebindingMap rebindings)
copy in class Expressionrebindings - variables that need to be re-boundpublic Pattern toPattern(Configuration config) throws XPathException
toPattern in class Expressionconfig - the Saxon configurationXPathException - if conversion is not possiblepublic PathMap.PathMapNodeSet addToPathMap(PathMap pathMap, PathMap.PathMapNodeSet pathMapNodeSet)
addToPathMap in class ExpressionpathMap - the PathMap to which the expression should be addedpathMapNodeSet - the set of nodes within the path mappublic final int getDependencies()
getDependencies in class Expressionpublic SequenceIterator<?> iterate(XPathContext context) throws XPathException
iterate in class Expressioncontext - 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 Expressioncontext - 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 Expressioncontext - The dynamic context, giving access to the current node,
the current variables, etc.XPathException - if a dynamic error occurspublic int getImplementationMethod()
ExpressiongetImplementationMethod in class ExpressionExpression.ITERATE_METHOD or Expression.EVALUATE_METHOD or
Expression.PROCESS_METHODpublic java.lang.CharSequence evaluateAsString(XPathContext context) throws XPathException
ExpressionevaluateAsString in class Expressioncontext - 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 Expressioncontext - 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 Expressioncontext - the XPath dynamic evaluation contextpul - the pending update list to which the results should be writtenXPathException - if evaluation failspublic boolean equals(java.lang.Object obj)
equals in class Expressionobj - the other expressionpublic int computeHashCode()
computeHashCode in class Expressionpublic java.lang.String toString()
toString in class Expressionpublic void export(ExpressionPresenter out) throws XPathException
export in interface ExportAgentexport in class Expressionout - the expression presenter used to display the structureXPathException - if the export fails, for example if an expression is found that won't work
in the target environment.public static void exportValue(Sequence<?> value, ExpressionPresenter out) throws XPathException
XPathExceptionpublic java.lang.String getExpressionName()
getExpressionName in class Expressionpublic static void exportAtomicValue(AtomicValue value, ExpressionPresenter out) throws XPathException
XPathExceptionpublic java.lang.String toShortString()
toShortString in class Expressionpublic 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 hasEffectiveBooleanValue(Expression exp, boolean value)
exp - an expressionvalue - true or falsepublic static boolean isConstantOne(Expression exp)
exp - an expressionpublic boolean isSubtreeExpression()
isSubtreeExpression in class Expressionpublic static Literal makeEmptySequence()
public static <T extends Item<?>> Literal makeLiteral(GroundedValue<T> value)
value - the value of this literalpublic static Literal makeLiteral(GroundedValue<?> value, Expression origin)
value - the literal valueorigin - the expression whose context and location information is to be retainedpublic java.lang.String getStreamerName()
getStreamerName in class ExpressionCopyright (c) 2004-2020 Saxonica Limited. All rights reserved.