net.sf.saxon.expr

Class CastableExpression

public final class CastableExpression extends UnaryExpression

Castable Expression: implements "Expr castable as atomic-type?". The implementation simply wraps a cast expression with a try/catch.
Field Summary
booleanallowEmpty
AtomicTypetargetType
Constructor Summary
CastableExpression(Expression source, AtomicType target, boolean allowEmpty)
Create a "castable" expression of the form "source castable as target"
Method Summary
booleanallowsEmpty()
Determine whether the empty sequence is allowed
intcomputeCardinality()
intcomputeSpecialProperties()
Determine the special properties of this expression
Expressioncopy()
Copy an expression.
booleaneffectiveBooleanValue(XPathContext context)
booleanequals(Object other)
Is this expression the same as another expression?
ItemevaluateItem(XPathContext context)
Evaluate the expression
voidexplain(ExpressionPresenter out)
Diagnostic print of expression structure.
ItemTypegetItemType(TypeHierarchy th)
Determine the data type of the result of the Castable expression
AtomicTypegetTargetType()
Get the target type
static booleanisCastable(AtomicValue value, AtomicType targetType, XPathContext context)
Determine whether a value is castable to a given type
Expressionoptimize(ExpressionVisitor visitor, ItemType contextItemType)
Optimize the expression
Expressionsimplify(ExpressionVisitor visitor)
Simplify the expression
ExpressiontypeCheck(ExpressionVisitor visitor, ItemType contextItemType)
Type-check the expression

Field Detail

allowEmpty

boolean allowEmpty

targetType

AtomicType targetType

Constructor Detail

CastableExpression

public CastableExpression(Expression source, AtomicType target, boolean allowEmpty)
Create a "castable" expression of the form "source castable as target"

Parameters: source The source expression target The type being tested against allowEmpty true if an empty sequence is acceptable, that is if the expression was written as "source castable as target?"

Method Detail

allowsEmpty

public boolean allowsEmpty()
Determine whether the empty sequence is allowed

Returns: true if an empty sequence is allowed

computeCardinality

public int computeCardinality()

computeSpecialProperties

public int computeSpecialProperties()
Determine the special properties of this expression

Returns: NON_CREATIVE.

copy

public Expression copy()
Copy an expression. This makes a deep copy.

Returns: the copy of the original expression

effectiveBooleanValue

public boolean effectiveBooleanValue(XPathContext context)

equals

public boolean equals(Object other)
Is this expression the same as another expression?

evaluateItem

public Item evaluateItem(XPathContext context)
Evaluate the expression

explain

public void explain(ExpressionPresenter out)
Diagnostic print of expression structure. The abstract expression tree is written to the supplied output destination.

getItemType

public ItemType getItemType(TypeHierarchy th)
Determine the data type of the result of the Castable expression

Parameters: th the type hierarchy cache

getTargetType

public AtomicType getTargetType()
Get the target type

Returns: the target type

isCastable

public static boolean isCastable(AtomicValue value, AtomicType targetType, XPathContext context)
Determine whether a value is castable to a given type

Parameters: value the value to be tested targetType the type to be tested against context XPath dynamic context

Returns: true if the value is castable to the required type

optimize

public Expression optimize(ExpressionVisitor visitor, ItemType contextItemType)
Optimize the expression

simplify

public Expression simplify(ExpressionVisitor visitor)
Simplify the expression

Parameters: visitor an expression visitor

Returns: the simplified expression

typeCheck

public Expression typeCheck(ExpressionVisitor visitor, ItemType contextItemType)
Type-check the expression