org.basex.query.iter
Class SeqIter

java.lang.Object
  extended by org.basex.query.iter.Iter
      extended by org.basex.query.iter.SeqIter
All Implemented Interfaces:
Result

public final class SeqIter
extends Iter
implements Result

Sequence iterator.

Author:
Workgroup DBIS, University of Konstanz 2005-10, ISC License, Christian Gruen

Field Summary
 Item[] item
          Items.
 
Fields inherited from class org.basex.query.iter.Iter
EMPTY
 
Constructor Summary
SeqIter()
          Constructor.
SeqIter(int c)
          Constructor.
SeqIter(Item[] it, int s)
          Constructor.
SeqIter(QueryContext c)
          Constructor, specifying the query context.
 
Method Summary
 void add(Item it)
          Adds a single item.
 void add(Iter iter)
          Adds the contents of an iterator.
 Item finish()
          Returns a sequence from all iterator values.
static SeqIter get(Iter iter)
          Returns the argument, if it is a sequence iterator.
 Item get(long i)
          Returns the specified item.
 Item next()
          Returns the next item or null if no other items are found.
 void pos(int p)
          Sets the iterator position.
 boolean reset()
          Resets the iterator and returns true.
 boolean same(Result v)
          Compares values for equality.
 void serialize(Serializer ser)
          Serializes the complete result.
 void serialize(Serializer ser, int n)
          Serializes the specified result.
 int size()
          Returns the number of entries.
 void size(int s)
          Sets the iterator size.
 String toString()
           
 
Methods inherited from class org.basex.query.iter.Iter
reverse
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

item

public Item[] item
Items.

Constructor Detail

SeqIter

public SeqIter()
Constructor.


SeqIter

public SeqIter(int c)
Constructor.

Parameters:
c - initial capacity

SeqIter

public SeqIter(QueryContext c)
Constructor, specifying the query context.

Parameters:
c - query context

SeqIter

public SeqIter(Item[] it,
               int s)
Constructor.

Parameters:
it - item array
s - size
Method Detail

get

public static SeqIter get(Iter iter)
                   throws QueryException
Returns the argument, if it is a sequence iterator. Otherwise, returns a new sequence iterator with the iterator contents.

Parameters:
iter - iterator
Returns:
iterator
Throws:
QueryException - query exception

add

public void add(Iter iter)
         throws QueryException
Adds the contents of an iterator.

Parameters:
iter - entry to be added
Throws:
QueryException - query exception

add

public void add(Item it)
Adds a single item.

Parameters:
it - item to be added

same

public boolean same(Result v)
Description copied from interface: Result
Compares values for equality.

Specified by:
same in interface Result
Parameters:
v - value to be compared
Returns:
true if values are equal

serialize

public void serialize(Serializer ser)
               throws IOException
Description copied from interface: Result
Serializes the complete result.

Specified by:
serialize in interface Result
Parameters:
ser - serializer
Throws:
IOException - I/O exception

serialize

public void serialize(Serializer ser,
                      int n)
               throws IOException
Description copied from interface: Result
Serializes the specified result.

Specified by:
serialize in interface Result
Parameters:
ser - serializer
n - results offset to serialize
Throws:
IOException - I/O exception

next

public Item next()
Description copied from class: Iter
Returns the next item or null if no other items are found.

Specified by:
next in class Iter
Returns:
resulting item

pos

public void pos(int p)
Sets the iterator position.

Parameters:
p - position

size

public void size(int s)
Sets the iterator size.

Parameters:
s - size

reset

public boolean reset()
Description copied from class: Iter
Resets the iterator and returns true. Note: false is returned if the iterator cannot be reset, so the returned value has to be checked.

Overrides:
reset in class Iter
Returns:
true if operator could be reset

size

public int size()
Description copied from class: Iter
Returns the number of entries. Note: -1 is returned if the number cannot be retrieved, so the returned value has to be checked. If this method is implemented, Iter.get(long) has to be implemented as well.

Specified by:
size in interface Result
Overrides:
size in class Iter
Returns:
number of entries

get

public Item get(long i)
Description copied from class: Iter
Returns the specified item. Note: null is returned if the item cannot be retrieved, so the returned value has to be checked.

Overrides:
get in class Iter
Parameters:
i - value offset
Returns:
specified item

finish

public Item finish()
Description copied from class: Iter
Returns a sequence from all iterator values. Should be called before Iter.next().

Overrides:
finish in class Iter
Returns:
sequence

toString

public String toString()
Overrides:
toString in class Object