org.basex.query.xquery.iter
Class Iter

java.lang.Object
  extended by org.basex.query.xquery.iter.Iter
Direct Known Subclasses:
NodeIter, RangeIter, SeqIter

public abstract class Iter
extends java.lang.Object

Iterator interface.

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

Field Summary
static Iter EMPTY
          Empty iterator.
 
Constructor Summary
Iter()
           
 
Method Summary
 Item atomic(Expr expr, boolean empty)
          Checks if the specified iterator contains a single item.
 Item ebv()
          Checks if the iterator can be dissolved into an effective boolean value.
 Item finish()
          Returns a sequence from all iterator values.
abstract  Item next()
          Returns the next item or null if no other items are found.
 void reset()
          Resets the iterator; can be optionally implemented.
static void seqErr(Item i1, Item i2, Item i3, Expr expr)
          Throws a sequence error.
 long size()
          Returns the number of entries.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY

public static final Iter EMPTY
Empty iterator.

Constructor Detail

Iter

public Iter()
Method Detail

next

public abstract Item next()
                   throws XQException
Returns the next item or null if no other items are found.

Returns:
resulting item
Throws:
XQException - evaluation exception

reset

public void reset()
Resets the iterator; can be optionally implemented.


size

public long size()
Returns the number of entries. Warning: -1 is returned if the number cannot be evaluated, so each method has to check and react on the returned value.

Returns:
number of entries

finish

public Item finish()
            throws XQException
Returns a sequence from all iterator values.

Returns:
sequence
Throws:
XQException - evaluation exception

ebv

public final Item ebv()
               throws XQException
Checks if the iterator can be dissolved into an effective boolean value. If not, returns an error. If yes, returns the first value - which can be also be e.g. an integer, which is later evaluated as position predicate. Must be called before next() was called.

Returns:
item
Throws:
XQException - evaluation exception

atomic

public final Item atomic(Expr expr,
                         boolean empty)
                  throws XQException
Checks if the specified iterator contains a single item. Returns null, the first item or an exception.

Parameters:
expr - calling expression
empty - allow empty sequences
Returns:
item
Throws:
XQException - evaluation exception

seqErr

public static void seqErr(Item i1,
                          Item i2,
                          Item i3,
                          Expr expr)
                   throws XQException
Throws a sequence error.

Parameters:
i1 - first item
i2 - first item
i3 - first item
expr - expression
Throws:
XQException - evaluation exception