|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.saxon.expr.Expression
net.sf.saxon.expr.Literal
public class Literal
A Literal is an expression whose value is constant: it is a class that implements the Expression interface as a wrapper around a Value. 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')
Field Summary |
---|
Fields inherited from class net.sf.saxon.expr.Expression |
---|
EVALUATE_METHOD, ITERATE_METHOD, PROCESS_METHOD |
Constructor Summary | |
---|---|
Literal(Value value)
Create a literal as a wrapper around a Value |
Method Summary | |
---|---|
int |
computeCardinality()
Determine the cardinality |
int |
computeSpecialProperties()
Compute the static properties of this expression (other than its type). |
void |
display(int level,
PrintStream out,
Configuration config)
Diagnostic display of the 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. |
String |
evaluateAsString(XPathContext context)
Evaluate an expression as a String. |
Item |
evaluateItem(XPathContext context)
Evaluate as a singleton item (or empty sequence). |
int |
getDependencies()
Determine which aspects of the context the expression depends on. |
ItemType |
getItemType(TypeHierarchy th)
Determine the data type of the items in the expression, if possible |
Value |
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. |
SequenceIterator |
iterate(XPathContext context)
Return an Iterator to iterate over the values of a sequence. |
static Literal |
makeLiteral(Value value)
Create a literal as a wrapper around a Value |
Expression |
optimize(Optimizer opt,
StaticContext env,
ItemType contextItemType)
Optimize an expression |
void |
process(XPathContext context)
Process the value as an instruction, without returning any tail calls |
Expression |
simplify(StaticContext env)
Simplify an expression |
Expression |
typeCheck(StaticContext env,
ItemType contextItemType)
TypeCheck an expression |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Literal(Value value)
value
- Method Detail |
---|
public static Literal makeLiteral(Value value)
value
- public Value getValue()
public final Expression simplify(StaticContext env)
simplify
in class Expression
public final Expression typeCheck(StaticContext env, ItemType contextItemType)
typeCheck
in class Expression
env
- the static context of the expressioncontextItemType
- 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
public final Expression optimize(Optimizer opt, StaticContext env, ItemType contextItemType)
optimize
in class Expression
opt
- the optimizer in use. This provides access to supporting functions; it also allows
different optimization strategies to be used in different circumstances.env
- the static context of the expressioncontextItemType
- 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
public ItemType getItemType(TypeHierarchy th)
getItemType
in class Expression
th
- The TypeHierarchy. Can be null if the target is an AtomicValue.
public int computeCardinality()
public int computeSpecialProperties()
StaticProperty.NON_CREATIVE
.
computeSpecialProperties
in class Expression
StaticProperty.NON_CREATIVE
public final int getDependencies()
getDependencies
in class Expression
public SequenceIterator iterate(XPathContext context) throws XPathException
iterate
in interface SequenceIterable
iterate
in class Expression
context
- supplies the context for evaluation
XPathException
- if any dynamic error occurs evaluating the
expressionpublic Item evaluateItem(XPathContext context) throws XPathException
evaluateItem
in interface EvaluableItem
evaluateItem
in class Expression
context
- The context in which the expression is to be evaluated
XPathException
- 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
public String evaluateAsString(XPathContext context) throws XPathException
Expression
evaluateAsString
in class Expression
context
- The context in which the expression is to be evaluated
XPathException
- 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 evaluated
XPathException
- if any dynamic error occurs evaluating the
expressionpublic boolean equals(Object obj)
equals
in class Object
obj
- the other expression
public int hashCode()
hashCode
in class Object
public void display(int level, PrintStream out, Configuration config)
display
in class Expression
level
- indentation level for this expressionout
- Output destinationpublic static boolean isAtomic(Expression exp)
exp
- an expression
public static boolean isEmptySequence(Expression exp)
exp
- an expression
public static boolean isConstantBoolean(Expression exp, boolean value)
exp
- an expressionvalue
- true or false
public static boolean isConstantOne(Expression exp)
exp
- an expression
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |