net.sf.saxon.expr
Class UntypedAtomicConverter

java.lang.Object
  extended bynet.sf.saxon.expr.ComputedExpression
      extended bynet.sf.saxon.expr.UntypedAtomicConverter
All Implemented Interfaces:
Expression, MappingFunction, java.io.Serializable

public final class UntypedAtomicConverter
extends ComputedExpression
implements MappingFunction

An UntypedAtomicConverter is an expression that converts any untypedAtomic items in a sequence to a specified type, returning all other items unchanged

See Also:
Serialized Form

Field Summary
 
Fields inherited from class net.sf.saxon.expr.ComputedExpression
lineNumber, NO_ARGUMENTS, staticProperties
 
Constructor Summary
UntypedAtomicConverter(Expression sequence, AtomicType requiredItemType)
          Constructor
 
Method Summary
 Expression analyze(StaticContext env)
          Type-check the expression
 int computeCardinality()
          Determine the static cardinality of the expression
 void display(int level, NamePool pool)
          Diagnostic print of expression structure
 Item evaluateItem(XPathContext context)
          Evaluate as an Item.
 ItemType getItemType()
          Determine the static type of the items returned by the expression, if possible
 Expression[] getSubExpressions()
          Get the immediate subexpressions of this expression
 SequenceIterator iterate(XPathContext context)
          Iterate over the sequence of values
 java.lang.Object map(Item item, XPathContext context, java.lang.Object info)
          Implement the mapping function
 Expression promote(PromotionOffer offer)
          Promote this expression if possible
 Expression simplify()
          Simplify an expression
 
Methods inherited from class net.sf.saxon.expr.ComputedExpression
computeDependencies, computeSpecialProperties, computeStaticProperties, dynamicError, effectiveBooleanValue, evaluateAsString, getCardinality, getDependencies, getIntrinsicDependencies, getLineNumber, getSpecialProperties, markTailFunctionCalls, setLineNumber, typeError
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UntypedAtomicConverter

public UntypedAtomicConverter(Expression sequence,
                              AtomicType requiredItemType)
Constructor

Method Detail

simplify

public Expression simplify()
                    throws XPathException
Simplify an 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

Specified by:
analyze in interface Expression
Parameters:
env - the static context of the expression
Returns:
the original expression, rewritten to perform necessary run-time type checks, and to perform other type-related optimizations
Throws:
XPathException - if an error is discovered during this phase (typically a type error)

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

iterate

public SequenceIterator iterate(XPathContext context)
                         throws XPathException
Iterate over the sequence of values

Specified by:
iterate in interface Expression
Overrides:
iterate in class ComputedExpression
Parameters:
context - supplies the context for evaluation
Returns:
a SequenceIterator that can be used to iterate over the result of the expression
Throws:
XPathException - if any dynamic error occurs evaluating the expression

evaluateItem

public Item evaluateItem(XPathContext context)
                  throws XPathException
Evaluate as an Item. This should only be called if the UntypedAtomicConverter has cardinality zero-or-one

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

map

public java.lang.Object map(Item item,
                            XPathContext context,
                            java.lang.Object info)
                     throws XPathException
Implement the mapping function

Specified by:
map in interface MappingFunction
Parameters:
item - The item to be mapped. If context is supplied, this must be the same as context.currentItem().
context - The processing context. This is supplied only for mapping constructs that set the context node, position, and size. Otherwise it is null.
info - Arbitrary information supplied by the creator of the MappingIterator. It must be read-only and immutable for the duration of the iteration.
Returns:
either (a) a SequenceIterator over the sequence of items that the supplied input item maps to, or (b) an Item if it maps to a single item, or (c) null if it maps to an empty sequence.
Throws:
XPathException

getItemType

public ItemType getItemType()
Determine the static type of the items returned by the expression, if possible

Specified by:
getItemType in interface Expression
Returns:
a value such as Type.STRING, Type.BOOLEAN, Type.NUMBER, Type.NODE, or Type.ITEM (meaning not known in advance)

computeCardinality

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

Specified by:
computeCardinality in class ComputedExpression

display

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

Specified by:
display in interface Expression
Parameters:
level - indentation level for this expression