## org.exist.xquery.value
Class AbstractSequence

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

All Implemented Interfaces:
  Sequence

Direct Known Subclasses:
  AbstractNodeSet, EmptySequence, OrderedValueSequence, PreorderedValueSequence, ValueSequence

public abstract class AbstractSequence
extends java.lang.Object
implements Sequence

An abstract implementation of `Sequence` with default implementations for some methods.

Field Summary

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

Method Summary
`abstract 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.
`void` `clearContext(int contextId)` For every item in the sequence, clear any context-dependant information that is stored during query processing.
`int` `conversionPreference(java.lang.Class javaClass)` Returns a preference indicator, indicating the preference of a value to be converted into the given Java class.
`AtomicValue` `convertTo(int requiredType)` Try to convert the sequence into an atomic value.
`boolean` `effectiveBooleanValue()` See <a <href="http://www.w3.org/TR/xquery/#id-ebv">2.4.3 Effective Boolean Value
`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.
`abstract int` `getItemType()` Return the primary type to which all items in this sequence belong.
`abstract int` `getLength()` Returns the number of items contained in the sequence.
`java.lang.String` `getStringValue()` Convert the sequence to a string.
`boolean` `hasMany()` Returns whether the sequence more than one item or not.
`abstract 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.
`abstract boolean` `isEmpty()` Returns whether the sequence is empty or not.
`boolean` `isPersistentSet()`
`abstract Item` `itemAt(int pos)` Returns the item located at the specified position within this sequence.
`abstract SequenceIterator` `iterate()` Returns an iterator over all items in the sequence.
`void` `setIsCached(boolean cached)` Indicates that the sequence is the result of a previous operation and has not been recomputed.
`void` `setSelfAsContext(int contextId)`
`java.lang.Object` `toJavaObject(java.lang.Class target)` Convert the value into an instance of the specified Java class.
`java.lang.String` `toString()`
`abstract 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`

Methods inherited from interface org.exist.xquery.value.Sequence
`removeDuplicates, toNodeSet`

Method Detail

### getItemType

    public abstract 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.

### iterate

    public abstract 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 abstract 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`

### getLength

    public abstract 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`

### convertTo

    public AtomicValue convertTo(int requiredType)
                          throws XPathException

  Description copied from interface: `Sequence`
  Try to convert the sequence into an atomic value. The target type should be specified by using one of the constants defined in class `Type`. An `XPathException` is thrown if the conversion is impossible.

  Specified by:
    `convertTo` in interface `Sequence`
  Parameters:
    `requiredType` - one of the type constants defined in class `Type`
  Throws:
    `XPathException`

### isEmpty

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

### getStringValue

    public java.lang.String getStringValue()
                                    throws XPathException

  Description copied from interface: `Sequence`
  Convert the sequence to a string.

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

### toString

    public java.lang.String toString()

### add

    public abstract 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`

### itemAt

    public abstract 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` -

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

### effectiveBooleanValue

    public boolean effectiveBooleanValue()
                                  throws XPathException

  See <a <href="http://www.w3.org/TR/xquery/#id-ebv">2.4.3 Effective Boolean Value

  Specified by:
    `effectiveBooleanValue` in interface `Sequence`
  Throws:
    `XPathException`
  See Also:
    `Sequence.effectiveBooleanValue()`

### 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 `Sequence`
  Parameters:
    `javaClass` -

### 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 `Sequence`
  Parameters:
    `target` -
  Throws:
    `XPathException`

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

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

### isPersistentSet

    public boolean isPersistentSet()

  Specified by:
    `isPersistentSet` in interface `Sequence`

Copyright (C) Wolfgang Meier. All rights reserved.