net.sf.saxon.value
Class AtomicValue

java.lang.Object
  |
  +--net.sf.saxon.value.Value
        |
        +--net.sf.saxon.value.AtomicValue
All Implemented Interfaces:
Expression, Item, java.io.Serializable
Direct Known Subclasses:
AnyURIValue, BooleanValue, CalendarValue, DurationValue, NumericValue, ObjectValue, QNameValue, StringValue

public abstract class AtomicValue
extends Value
implements Item

A AtomicValue is a value that isn't a sequence. More strictly, it is a sequence of length one.

See Also:
Serialized Form

Constructor Summary
AtomicValue()
           
 
Method Summary
abstract  AtomicValue convert(int requiredType)
          Convert the value to a given type.
 boolean effectiveBooleanValue(XPathContext context)
          Get the effective boolean value of the value
 java.lang.String evaluateAsString(XPathContext context)
          Evaluate as a string
 Item evaluateItem(XPathContext context)
          Evaluate the value (this simply returns the value unchanged)
 int getCardinality()
          Determine the static cardinality
 AtomicValue getComponent(int component)
          Method to extract components of a value.
 Value getTypedValue()
          Get the typed value of this item
 SequenceIterator iterate(XPathContext context)
          Iterate over the (single) item in the sequence
 
Methods inherited from class net.sf.saxon.value.Value
analyze, asItem, asValue, collapseWhitespace, conversionPreference, convertToJava, getDependencies, getSpecialProperties, getSubExpressions, inverse, normalizeWhitespace, promote, simplify, stringToInteger, stringToNumber, trimWhitespace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.saxon.om.Item
getItemType, getStringValue
 
Methods inherited from interface net.sf.saxon.expr.Expression
display, getItemType
 

Constructor Detail

AtomicValue

public AtomicValue()
Method Detail

getCardinality

public final int getCardinality()
Determine the static cardinality

Specified by:
getCardinality in interface Expression
Returns:
code identifying the cardinality
See Also:
Cardinality

convert

public abstract AtomicValue convert(int requiredType)
                             throws XPathException
Convert the value to a given type. The result of the conversion will be an atomic value of the required type.

Parameters:
requiredType - type code of the required atomic type
Returns:
the result of the conversion, if conversion was possible. This will always be an instance of the class corresponding to the type of value requested
Throws:
XPathException - if conversion is not allowed for this required type, or if the particular value cannot be converted

evaluateItem

public Item evaluateItem(XPathContext context)
                  throws XPathException
Evaluate the value (this simply returns the value unchanged)

Specified by:
evaluateItem in interface Expression
Parameters:
context - the evaluation context (not used in this implementation)
Returns:
the value, unchanged
Throws:
XPathException

iterate

public final SequenceIterator iterate(XPathContext context)
Iterate over the (single) item in the sequence

Specified by:
iterate in interface Expression
Parameters:
context - the evaluation context (not used in this implementation)
Returns:
a SequenceIterator that iterates over the single item in this value

evaluateAsString

public final java.lang.String evaluateAsString(XPathContext context)
                                        throws XPathException
Evaluate as a string

Specified by:
evaluateAsString in interface Expression
Parameters:
context - The context in which the expression is to be evaluated
Returns:
the value of the expression, evaluated in the current context. The expression must return a string or (); if the value of the expression is (), this method returns "".
Throws:
XPathException - if any dynamic error occurs evaluating the expression

getTypedValue

public final Value getTypedValue()
Get the typed value of this item

Specified by:
getTypedValue in interface Item
Returns:
the typed value of the expression (which is this value)

effectiveBooleanValue

public boolean effectiveBooleanValue(XPathContext context)
Get the effective boolean value of the value

Specified by:
effectiveBooleanValue in interface Expression
Parameters:
context - the evaluation context (not used in this implementation)
Returns:
true, unless the value is boolean false, numeric zero, or zero-length string

getComponent

public AtomicValue getComponent(int component)
                         throws XPathException
Method to extract components of a value. Implemented by some subclasses, but defined at this level for convenience

XPathException