## 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, Base64BinaryValue, BooleanValue, CalendarValue, DerivedAtomicValue, DurationValue, HexBinaryValue, NumericValue, ObjectValue, QNameValue, StringValue

public abstract class AtomicValue
extends Value
implements Item

A AtomicValue is a value that isn't a sequence and isn't a node. More strictly, it is any sequence of length one whose content is not a node.

See Also:
  Serialized Form

Field Summary

Fields inherited from interface net.sf.saxon.expr.Expression
`EVALUATE_METHOD, ITERATE_METHOD, PROCESS_METHOD`

Constructor Summary
`AtomicValue()`

Method Summary
`AtomicValue` `convert(AtomicType targetType, XPathContext context)` Convert the value to a given type.
`abstract AtomicValue` `convert(int requiredType, XPathContext context)` Convert the value to a given type.
`java.lang.Object` `convertToJava(java.lang.Class target, Configuration config, XPathContext context)` Convert to Java object (for passing to external functions)
`void` `display(int level, NamePool pool, java.io.PrintStream out)` Diagnostic print of expression structure
`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.
`int` `getImplementationMethod()` An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process().
`AtomicValue` `getPrimitiveValue()` Get the primitive value (the value in the value space).
`abstract java.lang.String` `getStringValue()` Convert the value to a string, using the serialization rules.
`SequenceIterator` `getTypedValue(Configuration config)` Get the typed value of this item
`SequenceIterator` `iterate(XPathContext context)` Iterate over the (single) item in the sequence
`void` `process(XPathContext context)` Process the instruction, without returning any tail calls
`java.lang.String` `toString()` Get string value.

Methods inherited from class net.sf.saxon.value.Value
`analyze, asItem, asValue, collapseWhitespace, convertJavaObjectToXPath, getDependencies, getParentExpression, getSpecialProperties, inverse, iterateSubExpressions, normalizeWhitespace, promote, simplify, stringToNumber, trimWhitespace`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface net.sf.saxon.expr.Expression
`getItemType`

Constructor Detail

### AtomicValue

    public AtomicValue()

Method Detail

### getImplementationMethod

    public int getImplementationMethod()

  An implementation of Expression must provide at least one of the methods evaluateItem(), iterate(), or process(). This method indicates which of these methods is prefered.

  Specified by:
    `getImplementationMethod` in interface `Expression`

### process

    public void process(XPathContext context)
                 throws XPathException

  Process the instruction, without returning any tail calls

  Specified by:
    `process` in interface `Expression`
  Parameters:
    `context` - The dynamic context, giving access to the current node, the current variables, etc.
    `XPathException`

### 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,
                                        XPathContext context)
                                 throws XPathException

  Convert the value to a given type. The result of the conversion will be an atomic value of the required type. This method works only where the target type is a built-in type.

  Parameters:
    `requiredType` - type code of the required atomic type
    `context` - the evaluation context. Used primarily for error reporting, since nearly all type conversions are context-independent. The value may be null if the context is not known.
  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

### convert

    public final AtomicValue convert(AtomicType targetType,
                                     XPathContext context)
                              throws XPathException

  Convert the value to a given type. The result of the conversion will be an atomic value of the required type. This method works where the target type is a built-in atomic type and also where it is a user-defined atomic type.

    `XPathException`

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

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

### getStringValue

    public abstract java.lang.String getStringValue()

  Convert the value to a string, using the serialization rules. For atomic values this is the same as a cast; for sequence values it gives a space-separated list. This method is refined for AtomicValues so that it never throws an Exception.

  Specified by:
    `getStringValue` in interface `Item`
  Specified by:
    `getStringValue` in class `Value`
  Returns:
    the string value of the item

### getTypedValue

    public final SequenceIterator getTypedValue(Configuration config)

  Get the typed value of this item

  Specified by:
    `getTypedValue` in interface `Item`
  Parameters:
    `config` - the configuration: this is needed because it provides access to schema information needed to interpret the type annotation
  Returns:
    the typed value of the expression (which is this value)

### getPrimitiveValue

    public AtomicValue getPrimitiveValue()

  Get the primitive value (the value in the value space). This returns an AtomicValue of a class that would be used to represent the primitive value. In effect this means that for built-in types, it returns the value itself, but for user-defined type, it returns the primitive value minus the type annotation. Note that getItemType() when applied to the result of this function does not not necessarily return a primitive type: for example, this function may return a value of type xdt:dayTimeDuration, which is not a primitive type as defined by `Type.isPrimitiveType(int)`

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

### toString

    public java.lang.String toString()

  Get string value. In general toString() for an atomic value displays the value as it would be written in XPath: that is, as a literal if available, or as a call on a constructor function otherwise.

  Overrides:
    `toString` in class `Value`

### display

    public final void display(int level,
                              NamePool pool,
                              java.io.PrintStream out)

  Diagnostic print of expression structure

  Specified by:
    `display` in interface `Expression`
  Parameters:
    `level` - the indentation level of the output
    `out` -
    `pool` - NamePool used to expand any names appearing in the expression

### convertToJava

    public java.lang.Object convertToJava(java.lang.Class target,
                                          Configuration config,
                                          XPathContext context)
                                   throws XPathException

  Convert to Java object (for passing to external functions)

  Specified by:
    `convertToJava` in class `Value`
  Parameters:
    `target` - The class required by the external function
    `config` - The configuration (needed for access to schema information)
  Returns:
    an object of the target class
    `XPathException`