Overview | Package | Class | Deprecated | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.exist.xquery.value
Class AtomicValue

    java.lang.Object
      org.exist.xquery.value.AtomicValue

All Implemented Interfaces:
  java.lang.Comparable, Indexable, Item, Sequence

Direct Known Subclasses:
  AnyURIValue, BinaryValue, BooleanValue, ComputableValue, FunctionReference, JavaObjectValue, QNameValue, StringValue, UntypedAtomicValue

public abstract class AtomicValue
extends java.lang.Object
implements Item, Sequence, Indexable

Represents an atomic value. All simple values that are not nodes extend AtomicValue. As every single item is also a sequence, this class implements both: Item and Sequence.

Author:
  wolf

Field Summary
`static AtomicValue` | `EMPTY_VALUE` An empty atomic value

Fields inherited from interface org.exist.xquery.value.Sequence
`EMPTY_SEQUENCE`

Constructor Summary
`AtomicValue()`

Method Summary
`void` | `add(Item item)` Add an item to the current sequence.
`void` | `addAll(Sequence other)` Add all items of the other sequence to this item.
`AtomicValue` | `atomize()`
`void` | `clearContext(int contextId)` For every item in the sequence, clear any context-dependant information that is stored during query processing.
`abstract int` | `compareTo(java.text.Collator collator, AtomicValue other)`
`abstract boolean` | `compareTo(java.text.Collator collator, int operator, AtomicValue other)`
`int` | `compareTo(java.lang.Object other)`
`boolean` | `contains(java.text.Collator collator, AtomicValue other)` Compares this atomic value to another.
`int` | `conversionPreference(java.lang.Class javaClass)` Returns a preference indicator, indicating the preference of a value to be converted into the given Java class.
`abstract AtomicValue` | `convertTo(int requiredType)` Convert this item into an atomic value, whose type corresponds to the specified target type.
`void` | `copyTo(DBBroker broker, DocumentBuilderReceiver receiver)`
`static AtomicValue` | `deserialize(byte[] data, int start, int len)`
`void` | `dump(ExpressionDumper dumper)` Dump a string representation of this value to the given ExpressionDumper.
`boolean` | `effectiveBooleanValue()` Get the effective boolean value of this sequence.
`boolean` | `endsWith(java.text.Collator collator, AtomicValue other)` Compares this atomic value to another.
`int` | `getCardinality()` Returns the cardinality of this sequence.
`DocumentSet` | `getDocumentSet()` Returns the set of documents from which the node items in this sequence have been selected.
`int` | `getItemType()` Return the primary type to which all items in this sequence belong.
`int` | `getLength()` Returns the number of items contained in the sequence.
`abstract java.lang.String` | `getStringValue()` Return the string value of this item (see the definition of string value in XPath).
`int` | `getType()` Return the type of this item according to the type constants defined in class `Type`.
`boolean` | `hasMany()` Returns whether the sequence more than one item or not.
`boolean` | `hasOne()` Returns whether the sequence has just one item or not.
`boolean` | `isCached()` Returns true if the sequence is the result of a previous operation and has been cached.
`boolean` | `isEmpty()` Returns whether the sequence is empty or not.
`boolean` | `isPersistentSet()`
`Item` | `itemAt(int pos)` Returns the item located at the specified position within this sequence.
`SequenceIterator` | `iterate()` Returns an iterator over all items in the sequence.
`abstract AtomicValue` | `max(java.text.Collator collator, AtomicValue other)`
`abstract AtomicValue` | `min(java.text.Collator collator, AtomicValue other)`
`AtomicValue` | `promote(AtomicValue otherValue)`
`void` | `removeDuplicates()` Explicitely remove all duplicate nodes from this sequence.
`byte[]` | `serialize(short collectionId, boolean caseSensitive)` Serialize the value plus collection and possibly element information to an array of bytes.
`byte[]` | `serializeValue(int offset, boolean caseSensitive)` Serialize the value to an array of bytes for the persistant storage.
`void` | `setIsCached(boolean cached)` Indicates that the sequence is the result of a previous operation and has not been recomputed.
`void` | `setSelfAsContext(int contextId)`
`boolean` | `startsWith(java.text.Collator collator, AtomicValue other)` Compares this atomic value to another.
`java.lang.Object` | `toJavaObject(java.lang.Class target)` Convert the value into an instance of the specified Java class.
`NodeSet` | `toNodeSet()` Convert the sequence into a NodeSet.
`void` | `toSAX(DBBroker broker, org.xml.sax.ContentHandler handler)`
`Sequence` | `toSequence()` Convert this item into a sequence, containing only the item.
`java.lang.String` | `toString()`
`SequenceIterator` | `unorderedIterator()` Returns an iterator over all items in the sequence.

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

Field Detail

### EMPTY_VALUE

    public static final AtomicValue EMPTY_VALUE

  An empty atomic value

Constructor Detail

### AtomicValue

    public AtomicValue()

Method Detail

### getType

    public int getType()

  Description copied from interface: `Item`
  Return the type of this item according to the type constants defined in class `Type`.

  Specified by:
    `getType` in interface `Item`

### getStringValue

    public abstract java.lang.String getStringValue()
                                             throws XPathException

  Description copied from interface: `Item`
  Return the string value of this item (see the definition of string value in XPath).

  Specified by:
    `getStringValue` in interface `Item`
  Throws:
    `XPathException`

### convertTo

    public abstract AtomicValue convertTo(int requiredType)
                                   throws XPathException

  Description copied from interface: `Item`
  Convert this item into an atomic value, whose type corresponds to the specified target type. requiredType should be one of the type constants defined in `Type`. An `XPathException` is thrown if the conversion is impossible.

  Specified by:
    `convertTo` in interface `Item`
  Parameters:
    `requiredType` -
  Throws:
    `XPathException`

### compareTo

    public abstract boolean compareTo(java.text.Collator collator,
                                      int operator,
                                      AtomicValue other)
                               throws XPathException

  Throws:
    `XPathException`

### compareTo

    public abstract int compareTo(java.text.Collator collator,
                                  AtomicValue other)
                           throws XPathException

  Throws:
    `XPathException`

### max

    public abstract AtomicValue max(java.text.Collator collator,
                                    AtomicValue other)
                             throws XPathException

  Throws:
    `XPathException`

### min

    public abstract AtomicValue min(java.text.Collator collator,
                                    AtomicValue other)
                             throws XPathException

  Throws:
    `XPathException`

### startsWith

    public boolean startsWith(java.text.Collator collator,
                              AtomicValue other)
                       throws XPathException

  Compares this atomic value to another. Returns true if the current value is of type string and its value starts with the string value of the other value.

  Parameters:
    `collator` - Collator used for string comparison.
    `other` -
  Throws:
    `XPathException` - if this is not a string.

### endsWith

    public boolean endsWith(java.text.Collator collator,
                            AtomicValue other)
                     throws XPathException

  Compares this atomic value to another. Returns true if the current value is of type string and its value ends with the string value of the other value.

  Parameters:
    `collator` - Collator used for string comparison.
    `other` -
  Throws:
    `XPathException` - if this is not a string.

### contains

    public boolean contains(java.text.Collator collator,
                            AtomicValue other)
                     throws XPathException

  Compares this atomic value to another. Returns true if the current value is of type string and its value contains the string value of the other value.

  Parameters:
    `collator` - Collator used for string comparison.
    `other` -
  Throws:
    `XPathException` - if this is not a string.

### getLength

    public int getLength()

  Description copied from interface: `Sequence`
  Returns the number of items contained in the sequence. Call this method only when necessary, since it can be resource consuming.

  Specified by:
    `getLength` in interface `Sequence`
  Returns:
    The sequence's length

### getCardinality

    public int getCardinality()

  Description copied from interface: `Sequence`
  Returns the cardinality of this sequence. The returned value is a combination of flags as defined in `Cardinality`.

  Specified by:
    `getCardinality` in interface `Sequence`
  See Also:
    `Cardinality`

### removeDuplicates

    public void removeDuplicates()

  Description copied from interface: `Sequence`
  Explicitely remove all duplicate nodes from this sequence.

  Specified by:
    `removeDuplicates` in interface `Sequence`

### iterate

    public SequenceIterator iterate()
                             throws XPathException

  Description copied from interface: `Sequence`
  Returns an iterator over all items in the sequence. The items are returned in document order where applicable.

  Specified by:
    `iterate` in interface `Sequence`
  Throws:
    `XPathException` - TODO

### unorderedIterator

    public SequenceIterator unorderedIterator()

  Description copied from interface: `Sequence`
  Returns an iterator over all items in the sequence. The returned items may - but need not - to be in document order.

  Specified by:
    `unorderedIterator` in interface `Sequence`

### getItemType

    public int getItemType()

  Description copied from interface: `Sequence`
  Return the primary type to which all items in this sequence belong. This is `Type.NODE` for node sets, `Type.ITEM` for other sequences with mixed items.

  Specified by:
    `getItemType` in interface `Sequence`
  Returns:
    the primary type of the items in this sequence.

### itemAt

    public Item itemAt(int pos)

  Description copied from interface: `Sequence`
  Returns the item located at the specified position within this sequence. Items are counted beginning at 0.

  Specified by:
    `itemAt` in interface `Sequence`
  Parameters:
    `pos` -

### toSequence

    public Sequence toSequence()

  Description copied from interface: `Item`
  Convert this item into a sequence, containing only the item.

  Specified by:
    `toSequence` in interface `Item`

### toSAX

    public void toSAX(DBBroker broker,
                      org.xml.sax.ContentHandler handler)
               throws org.xml.sax.SAXException

  Specified by:
    `toSAX` in interface `Item`
  Throws:
    `org.xml.sax.SAXException`

### copyTo

    public void copyTo(DBBroker broker,
                       DocumentBuilderReceiver receiver)
                throws org.xml.sax.SAXException

  Specified by:
    `copyTo` in interface `Item`
  Throws:
    `org.xml.sax.SAXException`

### isEmpty

    public boolean isEmpty()

  Description copied from interface: `Sequence`
  Returns whether the sequence is empty or not.

  Specified by:
    `isEmpty` in interface `Sequence`
  Returns:
    `true` is the sequence is empty

### hasOne

    public boolean hasOne()

  Description copied from interface: `Sequence`
  Returns whether the sequence has just one item or not.

  Specified by:
    `hasOne` in interface `Sequence`
  Returns:
    `true` is the sequence has just one item

### hasMany

    public boolean hasMany()

  Description copied from interface: `Sequence`
  Returns whether the sequence more than one item or not.

  Specified by:
    `hasMany` in interface `Sequence`
  Returns:
    `true` is the sequence more than one item

### add

    public void add(Item item)
             throws XPathException

  Description copied from interface: `Sequence`
  Add an item to the current sequence. An `XPathException` may be thrown if the item's type is incompatible with this type of sequence (e.g. if the sequence is a node set). The sequence may or may not allow duplicate values.

  Specified by:
    `add` in interface `Sequence`
  Parameters:
    `item` -
  Throws:
    `XPathException`

### addAll

    public void addAll(Sequence other)
                throws XPathException

  Description copied from interface: `Sequence`
  Add all items of the other sequence to this item. An `XPathException` may be thrown if the type of the items in the other sequence is incompatible with the primary type of this sequence.

  Specified by:
    `addAll` in interface `Sequence`
  Parameters:
    `other` -
  Throws:
    `XPathException`

### atomize

    public AtomicValue atomize()
                        throws XPathException

  Specified by:
    `atomize` in interface `Item`
  Throws:
    `XPathException`

### effectiveBooleanValue

    public boolean effectiveBooleanValue()
                                  throws XPathException

  Description copied from interface: `Sequence`
  Get the effective boolean value of this sequence. Will be false if the sequence is empty, true otherwise.

  Specified by:
    `effectiveBooleanValue` in interface `Sequence`
  Throws:
    `XPathException`

### toNodeSet

    public NodeSet toNodeSet()
                      throws XPathException

  Description copied from interface: `Sequence`
  Convert the sequence into a NodeSet. If the sequence contains items which are not nodes, an XPathException is thrown.

  Specified by:
    `toNodeSet` in interface `Sequence`
  Throws:
    `XPathException` - if the sequence contains items which are not nodes.

### getDocumentSet

    public DocumentSet getDocumentSet()

  Description copied from interface: `Sequence`
  Returns the set of documents from which the node items in this sequence have been selected. This is for internal use only.

  Specified by:
    `getDocumentSet` in interface `Sequence`

### promote

    public AtomicValue promote(AtomicValue otherValue)
                        throws XPathException

  Throws:
    `XPathException`

### dump

    public void dump(ExpressionDumper dumper)

  Dump a string representation of this value to the given ExpressionDumper.

  Parameters:
    `dumper` -

### conversionPreference

    public int conversionPreference(java.lang.Class javaClass)

  Description copied from interface: `Sequence`
  Returns a preference indicator, indicating the preference of a value to be converted into the given Java class. Low numbers mean that the value can be easily converted into the given class.

  Specified by:
    `conversionPreference` in interface `Item`

### toJavaObject

    public java.lang.Object toJavaObject(java.lang.Class target)
                                  throws XPathException

  Description copied from interface: `Sequence`
  Convert the value into an instance of the specified Java class.

  Specified by:
    `toJavaObject` in interface `Item`
  Throws:
    `XPathException`

### toString

    public java.lang.String toString()

### isCached

    public boolean isCached()

  Description copied from interface: `Sequence`
  Returns true if the sequence is the result of a previous operation and has been cached.

  Specified by:
    `isCached` in interface `Sequence`

### setIsCached

    public void setIsCached(boolean cached)

  Description copied from interface: `Sequence`
  Indicates that the sequence is the result of a previous operation and has not been recomputed.

  Specified by:
    `setIsCached` in interface `Sequence`
  Parameters:
    `cached` -

### clearContext

    public void clearContext(int contextId)

  Description copied from interface: `Sequence`
  For every item in the sequence, clear any context-dependant information that is stored during query processing. This feature is used for node sets, which may store information about their context node.

  Specified by:
    `clearContext` in interface `Sequence`

### setSelfAsContext

    public void setSelfAsContext(int contextId)

  Specified by:
    `setSelfAsContext` in interface `Sequence`

### isPersistentSet

    public boolean isPersistentSet()

  Specified by:
    `isPersistentSet` in interface `Sequence`

### deserialize

    public static final AtomicValue deserialize(byte[] data,
                                                int start,
                                                int len)
                                         throws EXistException

  Throws:
    `EXistException`

### serialize

    public byte[] serialize(short collectionId,
                            boolean caseSensitive)
                     throws EXistException

  Description copied from interface: `Indexable`
  Serialize the value plus collection and possibly element information to an array of bytes.

  Specified by:
    `serialize` in interface `Indexable`
  Parameters:
    `collectionId` - the collection id to use
    `caseSensitive` - only relevant for string values: if set to false, strings should be serialized in lower case
  Throws:
    `EXistException`

### serializeValue

    public byte[] serializeValue(int offset,
                                 boolean caseSensitive)
                          throws EXistException

  Description copied from interface: `Indexable`
  Serialize the value to an array of bytes for the persistant storage. The returned byte array has the following format: (offset-1 free bytes, byte type, byte[] value)

  Specified by:
    `serializeValue` in interface `Indexable`
  Parameters:
    `offset` - starting index for writing in array data
  Returns:
    the size actually writen in the array argument
  Throws:
    `EXistException`

### compareTo

    public int compareTo(java.lang.Object other)

  Specified by:
    `compareTo` in interface `java.lang.Comparable`

Overview | Package | Class | Deprecated | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright (C) Wolfgang Meier. All rights reserved.