Qizx/Open v0.4

net.xfra.qizxopen.xquery
Interface Value

All Superinterfaces:
Item
All Known Implementing Classes:
net.xfra.qizxopen.xquery.dt.BaseValue

public interface Value
extends Item

Represents the result of the evaluation of a XML Query, which is a sequence of Items.

The next() method must be repeatedly invoked to check that an item is available.

When next() returns true, the current item value can be retrieved through specialized methods asX() (defined in super-interface Item) according to its type.

Value has often the dual aspect of a sequence and an Item. It is not immutable, because of the next() method. It can be regenerated by bornAgain().


Nested Class Summary
static class Value.Empty
          The empty sequence.
 
Field Summary
static Value empty
          The empty sequence (single instance)
 
Fields inherited from interface net.xfra.qizxopen.xquery.Item
INCOMPARABLE
 
Method Summary
 Item asAtom()
          Gets the current item with atomization.
 Item asItem()
          Gets the current item (undefined result if end of sequence reached).
 Value bornAgain()
          Returns a new version of the sequence in its initial state.
 boolean next()
          Attempts to get the next atomic item.
 boolean nextCollection()
          Attempts to get the next atomic item, without expanding collections.
 long quickCount(EvalContext context)
          Optimized evaluation of count() or last().
 void setLazy(boolean lazy)
          Boosts iterations that dont need the item value (count(), skipping)
 boolean worthExpanding()
          Returns true if it is more efficient to keep the value as an iterator, and not to expand it into an array sequence.
 
Methods inherited from interface net.xfra.qizxopen.xquery.Item
asBoolean, asDecimal, asDouble, asFloat, asInteger, asNode, asString, compareTo, deepEqual, getType, isNode
 

Field Detail

empty

public static final Value empty
The empty sequence (single instance)

Method Detail

next

public boolean next()
             throws XQueryException
Attempts to get the next atomic item. If true is returned, the item value is available through one of the specialized accessors.

XQueryException

nextCollection

public boolean nextCollection()
                       throws XQueryException
Attempts to get the next atomic item, without expanding collections.

XQueryException

asItem

public Item asItem()
            throws TypeException
Gets the current item (undefined result if end of sequence reached).

TypeException

asAtom

public Item asAtom()
            throws TypeException
Gets the current item with atomization. If the current item is a Node, it is transparently transformed into a sequence of atomic values (in the future non Basic implementation), or simply to its string value (XQ Basic).

TypeException

bornAgain

public Value bornAgain()
Returns a new version of the sequence in its initial state. Value objects are in principle immutable, but due to the iterative implementation style (see the next() method), this is not actually true. Therefore when a value is used several times (in particular the value of a variable), there is a need for "regeneration".

NOTE: this needs not be a deep copy, because only the state of the iterator is concerned, not the underlying data.


worthExpanding

public boolean worthExpanding()
Returns true if it is more efficient to keep the value as an iterator, and not to expand it into an array sequence. This method is used when a value is stored into variable. It should return true only when the value is cheap to compute AND doesnt involve Node constructors (because of a problem of Node identity).


setLazy

public void setLazy(boolean lazy)
Boosts iterations that dont need the item value (count(), skipping)


quickCount

public long quickCount(EvalContext context)
                throws XQueryException
Optimized evaluation of count() or last(). Assumes the iterator to be in initial state.

Parameters:
context - evaluation context: used for debugging and timeout detection.
XQueryException

 Copyright Xavier FRANC 2003-2004