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, locationId, MAX_SEQUENCE_LENGTH, MAX_STRING_LENGTH, PROCESS_METHOD, staticProperties, UNBOUNDED_LOWER, UNBOUNDED_UPPER, WATCH_METHOD| Modifier | Constructor and Description |
|---|---|
protected |
Literal(GroundedValue value,
Container container)
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()
Determine the data type of the items in the expression, if possible
|
protected StreamingAdjunct |
getStreamingAdjunct()
Get a class 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(Container container)
Factory method to make an empty-sequence literal
|
static Literal |
makeLiteral(GroundedValue value,
Container container)
Factory method to create a literal as a wrapper around a Value (factory method)
|
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
|
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, checkForUpdatingSubexpressions, checkPermittedContents, clearStreamabilityData, computeDependencies, computeStaticProperties, doPromotion, dynamicError, explain, getCardinality, getColumnNumber, getConfiguration, getConstructType, getContainer, getEvaluationMethod, getExpressionName, getHostLanguage, getImplementationMethod, getIntrinsicDependencies, getLineNumber, getLocationId, getObjectName, getPosture, getProperties, getProperty, getPublicId, getSlotsUsed, getSpecialProperties, getStreamability, getSweep, getSystemId, hasVariableBinding, identityHashCode, implementsStaticTypeCheck, isIdentical, isUpdatingExpression, iterateEvents, makeStreamingAdjunct, markTailFunctionCalls, operandList, operands, promote, replaceOperand, resetLocalStaticProperties, setContainer, setEvaluationMethod, setFiltered, setFlattened, setLocationId, setPostureAndSweep, simplify, staticTypeCheck, suppressValidation, toStreamingPattern, typeError, unorderedprotected Literal(GroundedValue value, Container container)
value - the value of this literalcontainer - the container in the expression tree. Should not be null.
Saxon does not reject a null value for the container, but it may cause
subsequent failures if a container is not supplied at some stage.public 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 ItemType getItemType()
getItemType in class Expressionpublic int computeCardinality()
computeCardinality in class ExpressionStaticProperty.ALLOWS_ZERO_OR_ONE,
StaticProperty.EXACTLY_ONE, StaticProperty.ALLOWS_ONE_OR_MORE,
StaticProperty.ALLOWS_ZERO_OR_MOREpublic int computeSpecialProperties()
StaticProperty.NON_CREATIVE.computeSpecialProperties in class ExpressionStaticProperty.NON_CREATIVEpublic IntegerValue[] getIntegerBounds()
getIntegerBounds in class Expressionpublic boolean isVacuousExpression()
isVacuousExpression in class Expressionpublic Expression copy()
copy in class Expressionpublic Pattern toPattern(Configuration config, boolean is30) throws XPathException
toPattern in class Expressionconfig - 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 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 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(Object obj)
equals in class Objectobj - the other expressionpublic int hashCode()
public String toString()
toString in class Expressionpublic void explain(ExpressionPresenter out)
explain in class Expressionout - the expression presenter used to display the structurepublic 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 isConstantOne(Expression exp)
exp - an expressionpublic boolean isSubtreeExpression()
isSubtreeExpression in class Expressionpublic static Literal makeEmptySequence(Container container)
container - the container in the expression tree. Should not be null.
Saxon does not reject a null value for the container, but it may cause
subsequent failures if a container is not supplied at some stage.public static Literal makeLiteral(GroundedValue value, Container container)
value - the value of this literalcontainer - the container in the expression tree. Should not be null.
Saxon does not reject a null value for the container, but it may cause
subsequent failures if a container is not supplied at some stage.protected StreamingAdjunct getStreamingAdjunct()
ExpressiongetStreamingAdjunct in class Expressionpublic ExpressionCompiler getExpressionCompiler()
getExpressionCompiler in class ExpressionCopyright (c) 2004-2014 Saxonica Limited. All rights reserved.