org.exist.xquery.value
Class ValueSequence

java.lang.Object
  extended by org.exist.xquery.value.AbstractSequence
      extended by org.exist.xquery.value.ValueSequence
All Implemented Interfaces:
MemoryNodeSet, Sequence
Direct Known Subclasses:
InMemoryNodeSet

public class ValueSequence
extends AbstractSequence
implements MemoryNodeSet

A sequence that may contain a mixture of atomic values and nodes.

Author:
wolf

Field Summary
 
Fields inherited from interface org.exist.xquery.value.MemoryNodeSet
EMPTY
 
Fields inherited from interface org.exist.xquery.value.Sequence
EMPTY_SEQUENCE
 
Constructor Summary
ValueSequence()
           
ValueSequence(boolean ordered)
           
ValueSequence(int initialSize)
           
ValueSequence(Sequence otherSequence)
           
ValueSequence(Sequence otherSequence, boolean ordered)
           
 
Method Summary
 void add(Item item)
          Add an item to the current sequence.
 void addAll(Sequence otherSequence)
          Add all items of the other sequence to this item.
 void clear()
           
 void clearContext(int contextId)
          For every item in the sequence, clear any context-dependant information that is stored during query processing.
 Sequence getAncestors(boolean includeSelf, NodeTest test)
           
 Sequence getAttributes(NodeTest test)
           
 Sequence getChildren(NodeTest test)
           
 Iterator getCollectionIterator()
          Return an iterator on all collections referenced by documents contained in this sequence..
 Sequence getDescendantAttributes(NodeTest test)
           
 Sequence getDescendants(boolean includeSelf, NodeTest test)
           
 DocumentSet getDocumentSet()
          Returns the set of documents from which the node items in this sequence have been selected.
 Sequence getFollowing(NodeTest test)
           
 Sequence getFollowingSiblings(NodeTest test)
           
 String getHashKey()
          Returns a hashKey based on sequence item string values.
 int getItemCount()
          Returns the number of items contained in the sequence.
 int getItemType()
          Return the primary type to which all items in this sequence belong.
 Sequence getParents(NodeTest test)
           
 Sequence getPreceding(NodeTest test)
           
 Sequence getPrecedingSiblings(NodeTest test)
           
 Sequence getSelf(NodeTest test)
           
 int getState()
           
 boolean hasChanged(int previousState)
           
 boolean hasOne()
          Returns whether the sequence has just one item or not.
 boolean isCacheable()
           
 boolean isEmpty()
          Returns whether the sequence is empty or not.
 boolean isInMemorySet()
           
 boolean isOrdered()
           
 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.
 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 removeDuplicates()
          Explicitely remove all duplicate nodes from this sequence.
 void setHolderVariable(Variable var)
           
 void setIsOrdered(boolean ordered)
           
 void sortInDocumentOrder()
           
 MemoryNodeSet toMemNodeSet()
          Convert the sequence into an in-memory node set.
 NodeSet toNodeSet()
          Makes all in-memory nodes in this sequence persistent, so they can be handled like other node sets.
 String toString()
           
 SequenceIterator unorderedIterator()
          Returns an iterator over all items in the sequence.
 
Methods inherited from class org.exist.xquery.value.AbstractSequence
conversionPreference, convertTo, effectiveBooleanValue, getCardinality, getStringValue, hasMany, isCached, setIsCached, setSelfAsContext, toJavaObject
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.exist.xquery.value.Sequence
conversionPreference, convertTo, effectiveBooleanValue, getCardinality, getStringValue, hasMany, isCached, setIsCached, setSelfAsContext, toJavaObject
 

Constructor Detail

ValueSequence

public ValueSequence()

ValueSequence

public ValueSequence(boolean ordered)

ValueSequence

public ValueSequence(int initialSize)

ValueSequence

public ValueSequence(Sequence otherSequence)
              throws XPathException
Throws:
XPathException

ValueSequence

public ValueSequence(Sequence otherSequence,
                     boolean ordered)
              throws XPathException
Throws:
XPathException
Method Detail

clear

public void clear()

isEmpty

public boolean isEmpty()
Description copied from interface: Sequence
Returns whether the sequence is empty or not.

Specified by:
isEmpty in interface Sequence
Specified by:
isEmpty in class AbstractSequence
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
Specified by:
hasOne in class AbstractSequence
Returns:
true is the sequence has just one item

add

public void add(Item item)
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
Specified by:
add in class AbstractSequence

addAll

public void addAll(Sequence otherSequence)
            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
Overrides:
addAll in class AbstractSequence
Throws:
XPathException

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
Specified by:
getItemType in class AbstractSequence
Returns:
the primary type of the items in this 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
Specified by:
iterate in class AbstractSequence
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
Specified by:
unorderedIterator in class AbstractSequence

isOrdered

public boolean isOrdered()

setIsOrdered

public void setIsOrdered(boolean ordered)

getItemCount

public 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
Specified by:
getItemCount in class AbstractSequence
Returns:
The number of items in the 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
Specified by:
itemAt in class AbstractSequence

setHolderVariable

public void setHolderVariable(Variable var)

toNodeSet

public NodeSet toNodeSet()
                  throws XPathException
Makes all in-memory nodes in this sequence persistent, so they can be handled like other node sets.

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

toMemNodeSet

public MemoryNodeSet toMemNodeSet()
                           throws XPathException
Description copied from interface: Sequence
Convert the sequence into an in-memory node set. If the sequence contains items which are not nodes, an XPathException is thrown. For persistent node sets, this method will return null. Call Sequence.isPersistentSet() to check if the sequence is a persistent node set.

Specified by:
toMemNodeSet in interface Sequence
Throws:
XPathException - if the sequence contains items which are not nodes or is a persistent node set

isInMemorySet

public boolean isInMemorySet()

isPersistentSet

public boolean isPersistentSet()
Specified by:
isPersistentSet in interface Sequence
Overrides:
isPersistentSet in class AbstractSequence

sortInDocumentOrder

public void sortInDocumentOrder()

removeDuplicates

public void removeDuplicates()
Description copied from interface: Sequence
Explicitely remove all duplicate nodes from this sequence.

Specified by:
removeDuplicates in interface Sequence

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
Overrides:
clearContext in class AbstractSequence

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
Overrides:
nodeMoved in class AbstractSequence
See Also:
UpdateListener

getState

public int getState()
Specified by:
getState in interface Sequence
Overrides:
getState in class AbstractSequence

hasChanged

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

isCacheable

public boolean isCacheable()
Specified by:
isCacheable in interface Sequence
Overrides:
isCacheable in class AbstractSequence

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
Overrides:
getDocumentSet in class AbstractSequence

getAttributes

public Sequence getAttributes(NodeTest test)
                       throws XPathException
Specified by:
getAttributes in interface MemoryNodeSet
Throws:
XPathException

getDescendantAttributes

public Sequence getDescendantAttributes(NodeTest test)
                                 throws XPathException
Specified by:
getDescendantAttributes in interface MemoryNodeSet
Throws:
XPathException

getChildren

public Sequence getChildren(NodeTest test)
                     throws XPathException
Specified by:
getChildren in interface MemoryNodeSet
Throws:
XPathException

getDescendants

public Sequence getDescendants(boolean includeSelf,
                               NodeTest test)
                        throws XPathException
Specified by:
getDescendants in interface MemoryNodeSet
Throws:
XPathException

getAncestors

public Sequence getAncestors(boolean includeSelf,
                             NodeTest test)
                      throws XPathException
Specified by:
getAncestors in interface MemoryNodeSet
Throws:
XPathException

getParents

public Sequence getParents(NodeTest test)
                    throws XPathException
Specified by:
getParents in interface MemoryNodeSet
Throws:
XPathException

getSelf

public Sequence getSelf(NodeTest test)
                 throws XPathException
Specified by:
getSelf in interface MemoryNodeSet
Throws:
XPathException

getPrecedingSiblings

public Sequence getPrecedingSiblings(NodeTest test)
                              throws XPathException
Specified by:
getPrecedingSiblings in interface MemoryNodeSet
Throws:
XPathException

getPreceding

public Sequence getPreceding(NodeTest test)
                      throws XPathException
Specified by:
getPreceding in interface MemoryNodeSet
Throws:
XPathException

getFollowingSiblings

public Sequence getFollowingSiblings(NodeTest test)
                              throws XPathException
Specified by:
getFollowingSiblings in interface MemoryNodeSet
Throws:
XPathException

getFollowing

public Sequence getFollowing(NodeTest test)
                      throws XPathException
Specified by:
getFollowing in interface MemoryNodeSet
Throws:
XPathException

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
Overrides:
getCollectionIterator in class AbstractSequence

toString

public String toString()
Overrides:
toString in class AbstractSequence

getHashKey

public String getHashKey()
Returns a hashKey based on sequence item string values. This function is faster than toString() but need to be enhanced. Warning : don't use except for experimental GroupBy clause. author Boris Verhaegen

See Also:
GroupedValueSequenceTable


Copyright (C) Wolfgang Meier. All rights reserved.