net.sf.saxon.expr
Class InstanceOfExpression

java.lang.Object
  |
  +--net.sf.saxon.expr.ComputedExpression
        |
        +--net.sf.saxon.expr.InstanceOfExpression
All Implemented Interfaces:
Expression, java.io.Serializable

public final class InstanceOfExpression
extends ComputedExpression

InstanceOf Expression: implements "Expr instance of data-type"

See Also:
Serialized Form

Field Summary
 
Fields inherited from class net.sf.saxon.expr.ComputedExpression
lineNumber, NO_ARGUMENTS, staticProperties
 
Constructor Summary
InstanceOfExpression(Expression source, SequenceType target)
           
 
Method Summary
 Expression analyze(StaticContext env)
          Type-check the expression
 int computeCardinality()
          Determine the cardinality
 void display(int level, NamePool pool)
          Diagnostic print of expression structure
 boolean effectiveBooleanValue(XPathContext context)
          Evaluate the expression as a boolean
 Item evaluateItem(XPathContext context)
          Evaluate the expression
 ItemType getItemType()
          Determine the data type of the result of the InstanceOf expression
 Expression[] getSubExpressions()
          Get the immediate subexpressions of this expression
 Expression promote(PromotionOffer offer)
          Promote this expression if possible
 Expression simplify()
          Simplify the expression
 
Methods inherited from class net.sf.saxon.expr.ComputedExpression
computeDependencies, computeSpecialProperties, computeStaticProperties, dynamicError, evaluateAsString, getCardinality, getDependencies, getIntrinsicDependencies, getLineNumber, getSourceLocator, getSpecialProperties, iterate, markTailFunctionCalls, setLineNumber, typeError
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InstanceOfExpression

public InstanceOfExpression(Expression source,
                            SequenceType target)
Method Detail

simplify

public Expression simplify()
                    throws XPathException
Simplify the expression

Specified by:
simplify in interface Expression
Overrides:
simplify in class ComputedExpression
Returns:
the simplified expression
Throws:
XPathException - if an error is discovered during expression rewriting

analyze

public Expression analyze(StaticContext env)
                   throws XPathException
Type-check the expression

Parameters:
env - the static context of the expression
Returns:
the checked expression
XPathException

promote

public Expression promote(PromotionOffer offer)
                   throws XPathException
Promote this expression if possible

Specified by:
promote in interface Expression
Overrides:
promote in class ComputedExpression
Parameters:
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 expression
Returns:
if the offer is not accepted, return this expression unchanged. Otherwise return the result of rewriting the expression to promote this subexpression
Throws:
XPathException - if any error is detected

getSubExpressions

public Expression[] getSubExpressions()
Get the immediate subexpressions of this expression

Specified by:
getSubExpressions in interface Expression
Overrides:
getSubExpressions in class ComputedExpression
Returns:
an array containing the sub-expressions of this expression

computeCardinality

public int computeCardinality()
Determine the cardinality

Specified by:
computeCardinality in class ComputedExpression

getItemType

public ItemType getItemType()
Determine the data type of the result of the InstanceOf expression

Returns:
a value such as Type.STRING, Type.BOOLEAN, Type.NUMBER, Type.NODE, or Type.ITEM (meaning not known at compile time)

evaluateItem

public Item evaluateItem(XPathContext context)
                  throws XPathException
Evaluate the expression

Specified by:
evaluateItem in interface Expression
Overrides:
evaluateItem in class ComputedExpression
Parameters:
context - The context in which the expression is to be evaluated
Returns:
the node or atomic value that results from evaluating the expression; or null to indicate that the result is an empty sequence
Throws:
XPathException - if any dynamic error occurs evaluating the expression

effectiveBooleanValue

public boolean effectiveBooleanValue(XPathContext context)
                              throws XPathException
Evaluate the expression as a boolean

Specified by:
effectiveBooleanValue in interface Expression
Overrides:
effectiveBooleanValue in class ComputedExpression
Parameters:
context - The context in which the expression is to be evaluated
Returns:
the effective boolean value
Throws:
XPathException - if any dynamic error occurs evaluating the expression

display

public void display(int level,
                    NamePool pool)
Diagnostic print of expression structure

Parameters:
level - indentation level for this expression