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 |
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)
Factory method to create a literal as a wrapper around a Value (factory method)
|
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 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,
boolean is30)
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, hasVariableBinding, identityHashCode, implementsStaticTypeCheck, isCallOn, isCallOnSystemFunction, isIdentical, isInstruction, isLiftable, isMultiThreaded, isSameExpression, isStaticPropertiesKnown, isUpdatingExpression, markTailFunctionCalls, operandList, operands, operandSparseList, optimizeChildren, resetLocalStaticProperties, restoreParentPointers, setEvaluationMethod, setExtraProperty, setFiltered, setFlattened, setLocation, setParentExpression, setRetainedStaticContext, setRetainedStaticContextLocally, setRetainedStaticContextThoroughly, setStaticProperty, simplify, simplifyChildren, staticTypeCheck, suppressValidation, typeCheckChildren, typeError, unordered, verifyParentPointers, verifyParentPointers
protected 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 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 getNetCost()
getNetCost
in class Expression
public ItemType getItemType()
getItemType
in class Expression
public UType getStaticUType(UType contextItemType)
getStaticUType
in class Expression
contextItemType
- the static context item typepublic 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(RebindingMap rebindings)
copy
in class Expression
rebindings
- 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 java.lang.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(java.lang.Object obj)
equals
in class java.lang.Object
obj
- the other expressionpublic int computeHashCode()
computeHashCode
in class Expression
public java.lang.String toString()
toString
in class Expression
public void export(ExpressionPresenter out) throws XPathException
export
in interface ExportAgent
export
in class Expression
out
- 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
XPathException
public java.lang.String getExpressionName()
getExpressionName
in class Expression
public static void exportAtomicValue(AtomicValue value, ExpressionPresenter out) throws XPathException
XPathException
public java.lang.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 hasEffectiveBooleanValue(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 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 Expression
Copyright (c) 2004-2018 Saxonica Limited. All rights reserved.