net.sf.saxon.expr

Class CastExpression

public final class CastExpression extends UnaryExpression

Cast Expression: implements "cast as data-type ( expression )". It also allows an internal cast, which has the same semantics as a user-requested cast, but maps an empty sequence to an empty sequence.
Field Summary
static IntHashMapcastingTable
Constructor Summary
CastExpression(Expression source, AtomicType target, boolean allowEmpty)
Method Summary
static voidaddAllowedCasts(int source, int[] target)
intcomputeCardinality()
Get the static cardinality of the expression
intcomputeSpecialProperties()
Determine the special properties of this expression
protected StringdisplayOperator(NamePool pool)
Give a string representation of the operator for use in diagnostics
AtomicValuedoQNameCast(StaticContext env)
Handle a cast to QName or NOTATION.
booleanequals(Object other)
Is this expression the same as another expression?
ItemevaluateItem(XPathContext context)
Evaluate the expression
ItemTypegetItemType(TypeHierarchy th)
Get the static type of the expression
static booleanisPossibleCast(int source, int target)
Determine whether casting from a source type to a target type is possible
Expressionsimplify(StaticContext env)
Simplify the expression
ExpressiontypeCheck(StaticContext env, ItemType contextItemType)
Type-check the expression

Field Detail

castingTable

static IntHashMap castingTable

Constructor Detail

CastExpression

public CastExpression(Expression source, AtomicType target, boolean allowEmpty)

Method Detail

addAllowedCasts

static void addAllowedCasts(int source, int[] target)

computeCardinality

public int computeCardinality()
Get the static cardinality of the expression

computeSpecialProperties

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

Returns: NON_CREATIVE.

displayOperator

protected String displayOperator(NamePool pool)
Give a string representation of the operator for use in diagnostics

Returns: the operator, as a string

doQNameCast

public AtomicValue doQNameCast(StaticContext env)
Handle a cast to QName or NOTATION. The argument must be a string literal.

equals

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

evaluateItem

public Item evaluateItem(XPathContext context)
Evaluate the expression

getItemType

public ItemType getItemType(TypeHierarchy th)
Get the static type of the expression

Parameters: th

isPossibleCast

public static boolean isPossibleCast(int source, int target)
Determine whether casting from a source type to a target type is possible

Parameters: source a primitive type (one that has an entry in the casting table) target another primitive type

Returns: true if the entry in the casting table is either "Y" (casting always succeeds) or "M" (casting allowed but may fail for some values)

simplify

public Expression simplify(StaticContext env)
Simplify the expression

Returns: the simplified expression

typeCheck

public Expression typeCheck(StaticContext env, ItemType contextItemType)
Type-check the expression