net.sf.saxon.expr

Class NumericPromoter

Implemented Interfaces:
EvaluableItem, InstructionInfoProvider, SequenceIterable, Serializable, SourceLocator

public final class NumericPromoter
extends UnaryExpression

A NumericPromoter performs numeric promotion on each item in a supplied sequence

Field Summary

Fields inherited from class net.sf.saxon.expr.UnaryExpression

operand

Fields inherited from class net.sf.saxon.expr.Expression

EVALUATE_METHOD, ITERATE_METHOD, PROCESS_METHOD, locationId, staticProperties

Constructor Summary

NumericPromoter(Expression sequence, BuiltInAtomicType requiredType)
Constructor

Method Summary

Expression
copy()
Copy an expression.
boolean
equals(Object other)
Is this expression the same as another expression?
Item
evaluateItem(XPathContext context)
Evaluate as an Item.
void
explain(ExpressionPresenter out)
Diagnostic print of expression structure.
ItemType
getItemType(TypeHierarchy th)
Determine the data type of the items returned by the expression, if possible
int
getRequiredType()
Get the required type.
SequenceIterator
iterate(XPathContext context)
Iterate over the sequence of values
Expression
optimize(ExpressionVisitor visitor, ItemType contextItemType)
Optimize the expression
Expression
simplify(ExpressionVisitor visitor)
Simplify an expression
Expression
typeCheck(ExpressionVisitor visitor, ItemType contextItemType)
Type-check the expression

Methods inherited from class net.sf.saxon.expr.UnaryExpression

computeCardinality, computeSpecialProperties, displayExpressionName, displayOperator, equals, explain, getBaseExpression, getItemType, hashCode, iterateSubExpressions, optimize, promote, replaceSubExpression, simplify, toString, typeCheck

Methods inherited from class net.sf.saxon.expr.Expression

addToPathMap, adoptChildExpression, checkPermittedContents, computeCardinality, computeDependencies, computeSpecialProperties, computeStaticProperties, copy, display, doPromotion, dynamicError, effectiveBooleanValue, evaluateAsString, evaluateItem, explain, explain, findParentOf, getCardinality, getColumnNumber, getConstructType, getContainer, getDependencies, getExecutable, getHostLanguage, getImplementationMethod, getInstructionInfo, getIntrinsicDependencies, getItemType, getLineNumber, getLocationId, getLocationProvider, getPublicId, getSlotsUsed, getSpecialProperties, getSystemId, hasLoopingSubexpression, implementsStaticTypeCheck, iterate, iterateEvents, iterateSubExpressions, markTailFunctionCalls, optimize, process, promote, replaceSubExpression, resetLocalStaticProperties, setContainer, setFiltered, setFlattened, setLocationId, simplify, staticTypeCheck, suppressValidation, toString, typeCheck, typeError

Constructor Details

NumericPromoter

public NumericPromoter(Expression sequence,
                       BuiltInAtomicType requiredType)
Constructor
Parameters:
sequence - this must be a sequence of atomic values. This is not checked; a ClassCastException will occur if the precondition is not satisfied.
requiredType - the item type to which all items in the sequence should be converted, using the rules for "cast as".

Method Details

copy

public Expression copy()
Copy an expression. This makes a deep copy.
Overrides:
copy in interface Expression
Returns:
the copy of the original expression

equals

public boolean equals(Object other)
Is this expression the same as another expression?
Overrides:
equals in interface UnaryExpression

evaluateItem

public Item evaluateItem(XPathContext context)
            throws XPathException
Evaluate as an Item. This should only be called if the expression has cardinality zero-or-one
Specified by:
evaluateItem in interface EvaluableItem
Overrides:
evaluateItem in interface Expression

explain

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

getItemType

public ItemType getItemType(TypeHierarchy th)
Determine the data type of the items returned by the expression, if possible
Overrides:
getItemType in interface UnaryExpression
Parameters:
th - the type hierarchy cache
Returns:
a value such as Type.STRING, Type.BOOLEAN, Type.NUMBER, Type.NODE, or Type.ITEM (meaning not known in advance)

getRequiredType

public int getRequiredType()
Get the required type. Always StandardNames.XS_DOUBLE or StandardNames.XS_FLOAT
Returns:
the fingerprint of the name of the required type

iterate

public SequenceIterator iterate(XPathContext context)
            throws XPathException
Iterate over the sequence of values
Specified by:
iterate in interface SequenceIterable
Overrides:
iterate in interface Expression

optimize

public Expression optimize(ExpressionVisitor visitor,
                           ItemType contextItemType)
            throws XPathException
Optimize the expression
Overrides:
optimize in interface UnaryExpression

simplify

public Expression simplify(ExpressionVisitor visitor)
            throws XPathException
Simplify an expression
Overrides:
simplify in interface UnaryExpression
Parameters:
visitor - an expression visitor

typeCheck

public Expression typeCheck(ExpressionVisitor visitor,
                            ItemType contextItemType)
            throws XPathException
Type-check the expression
Overrides:
typeCheck in interface UnaryExpression