org.exist.xquery.value
Class AbstractSequence

java.lang.Object
  extended by org.exist.xquery.value.AbstractSequence
All Implemented Interfaces:
Sequence
Direct Known Subclasses:
AbstractNodeSet, EmptySequence, GroupedValueSequence, OrderedValueSequence, PreorderedValueSequence, ValueSequence

public abstract class AbstractSequence
extends 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(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 2.4.3 Effective Boolean Value
 int getCardinality()
          Returns the cardinality of this sequence.
 Iterator getCollectionIterator()
          Return an iterator on all collections referenced by documents contained in this sequence..
 DocumentSet getDocumentSet()
          Returns the set of documents from which the node items in this sequence have been selected.
abstract  int getItemCount()
          Returns the number of items contained in the sequence.
abstract  int getItemType()
          Return the primary type to which all items in this sequence belong.
 int getState()
           
 String getStringValue()
          Convert the sequence to a string.
 boolean hasChanged(int previousState)
           
 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 isCacheable()
           
 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 nodeMoved(NodeId oldNodeId, StoredNode newNode)
          Node sets may implement this method to be informed of storage address and node id changes after updates.
 void setIsCached(boolean cached)
          Indicates that the sequence is the result of a previous operation and has not been recomputed.
 void setSelfAsContext(int contextId)
           
 Object toJavaObject(Class target)
          Convert the value into an instance of the specified Java class.
 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, toMemNodeSet, 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()
                                            throws XPathException
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
Throws:
XPathException

getItemCount

public abstract int getItemCount()
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:
getItemCount in interface Sequence
Returns:
The number of items in the sequence

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 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 String toString()
Overrides:
toString in class Object

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

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

getCollectionIterator

public Iterator getCollectionIterator()
Description copied from interface: Sequence
Return an iterator on all collections referenced by documents contained in this sequence..

Specified by:
getCollectionIterator in interface Sequence

nodeMoved

public void nodeMoved(NodeId oldNodeId,
                      StoredNode newNode)
Description copied from interface: Sequence
Node sets may implement this method to be informed of storage address and node id changes after updates.

Specified by:
nodeMoved in interface Sequence
See Also:
UpdateListener

effectiveBooleanValue

public boolean effectiveBooleanValue()
                              throws XPathException
See 2.4.3 Effective Boolean Value

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

conversionPreference

public int conversionPreference(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

toJavaObject

public Object toJavaObject(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
Throws:
XPathException

clearContext

public void clearContext(int contextId)
                  throws XPathException
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
Throws:
XPathException

setSelfAsContext

public void setSelfAsContext(int contextId)
                      throws XPathException
Specified by:
setSelfAsContext in interface Sequence
Throws:
XPathException

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

isPersistentSet

public boolean isPersistentSet()
Specified by:
isPersistentSet in interface Sequence

isCacheable

public boolean isCacheable()
Specified by:
isCacheable in interface Sequence

getState

public int getState()
Specified by:
getState in interface Sequence

hasChanged

public boolean hasChanged(int previousState)
Specified by:
hasChanged in interface Sequence


Copyright (C) Wolfgang Meier. All rights reserved.