net.sf.saxon.expr
Class ConvertToString

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

public final class ConvertToString
extends ComputedExpression

A ConvertToString expression performs the string conversion required for string arguments in backwards compatibility mode. If given an empty sequence, it returns an empty string; otherwise, it returns the string value of the first item in the sequence.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class net.sf.saxon.expr.ComputedExpression
lineNumber, NO_ARGUMENTS, staticProperties
 
Constructor Summary
ConvertToString(Expression base)
          Constructor
 
Method Summary
 Expression analyze(StaticContext env)
          Type-check the expression
 int computeCardinality()
          Get the static cardinality
 void display(int level, NamePool pool)
          Diagnostic print of expression structure
 boolean equals(Object other)
          Is this expression the same as another expression?
 Item evaluateItem(XPathContext context)
          Evaluate the expression
 ItemType getItemType()
          Get the data type of the items returned
 Expression[] getSubExpressions()
          Get the immediate subexpressions of this expression
 int hashCode()
          get HashCode for comparing two expressions
 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, effectiveBooleanValue, evaluateAsString, getCardinality, getDependencies, getIntrinsicDependencies, getLineNumber, getSpecialProperties, iterate, markTailFunctionCalls, setLineNumber, typeError
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConvertToString

public ConvertToString(Expression base)
Constructor

Parameters:
base - A sequence expression denoting sequence whose first item is to be returned
Method Detail

getItemType

public ItemType getItemType()
Get the data type of the items returned

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

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 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

computeCardinality

public int computeCardinality()
Get the static cardinality

Specified by:
computeCardinality in class ComputedExpression

equals

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


hashCode

public int hashCode()
get HashCode for comparing two expressions


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

display

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

Parameters:
level - indentation level for this expression