org.basex.query.value.item
Class Item

java.lang.Object
  extended by org.basex.data.ExprInfo
      extended by org.basex.query.expr.Expr
          extended by org.basex.query.value.Value
              extended by org.basex.query.value.item.Item
All Implemented Interfaces:
java.lang.Iterable<Item>
Direct Known Subclasses:
ADateDur, ANode, ANum, AStr, Atm, Bin, Bln, FItem, Jav, QNm

public abstract class Item
extends Value

Abstract super class for all items.

Author:
BaseX Team 2005-12, BSD License, Christian Gruen

Nested Class Summary
 
Nested classes/interfaces inherited from class org.basex.query.expr.Expr
Expr.Flag
 
Field Summary
 java.lang.Double score
          Score value.
static int UNDEF
          Undefined item.
 
Fields inherited from class org.basex.query.value.Value
type
 
Constructor Summary
protected Item(Type t)
          Constructor.
 
Method Summary
 boolean bool(InputInfo ii)
          Returns a boolean representation of the value.
protected  QueryException castErr(java.lang.Object val, InputInfo ii)
          Throws a cast error.
 boolean comparable(Item it)
          Checks if the items can be compared.
 double dbl(InputInfo ii)
          Returns a double representation of the value.
 java.math.BigDecimal dec(InputInfo ii)
          Returns a decimal representation of the value.
 java.lang.String description()
          Returns a string description of the expression.
 int diff(Item it, Collation coll, InputInfo ii)
          Returns the difference between the current and the specified item.
 Item ebv(QueryContext ctx, InputInfo ii)
          Checks if the iterator can be dissolved into an effective boolean value.
abstract  boolean eq(Item it, Collation coll, InputInfo ii)
          Checks the items for equality.
 boolean equiv(Item it, Collation coll, InputInfo ii)
          Checks the items for equivalence.
 float flt(InputInfo ii)
          Returns a float representation of the value.
 int hash(InputInfo ii)
          Returns a hash code for this value.
 boolean homogeneous()
          Checks if all items of this value share the same type.
 BufferInput input(InputInfo ii)
          Returns an input stream.
 boolean isItem()
          Tests if this is an item.
 Item item(QueryContext ctx, InputInfo ii)
          Evaluates the expression and returns the resulting item or a null reference, if the expression yields an empty sequence.
 Item itemAt(long pos)
          Gets the item at the given position in the value.
 ValueIter iter()
          Returns an iterator.
 boolean iterable()
          Returns true if the expression is iterable, i.e., if it will not contain any duplicate nodes and if all nodes will be are sorted.
 long itr(InputInfo ii)
          Returns an integer (long) representation of the value.
 Item materialize(InputInfo ii)
          Materializes streamable values, or returns a self reference.
 void plan(FElem plan)
          Creates an expression tree.
 double score()
          Returns a score value.
 void score(double s)
          Sets a new score value.
 long size()
          Returns the sequence size or 1.
abstract  byte[] string(InputInfo ii)
          Returns a string representation of the value.
 Item test(QueryContext ctx, InputInfo ii)
          Performs a predicate test and returns the item if test was successful.
 SeqType type()
          Returns the static type of the evaluated value.
 Type.ID typeId()
          Returns a type id.
 int writeTo(Item[] arr, int start)
          Writes this value's items out to the given array.
 byte[] xdmInfo()
          Returns data model info.
 
Methods inherited from class org.basex.query.value.Value
accept, cache, checkUp, compile, copy, count, data, exprSize, has, inline, isValue, iter, iterator, removable, serialize, toJava, value
 
Methods inherited from class org.basex.query.expr.Expr
addText, compEbv, copy, hasFreeVars, indexAccessible, indexEquivalent, inlineAll, isEmpty, isFunction, isVacuous, markTailCalls, optimize, sameAs, uses, visitAll
 
Methods inherited from class org.basex.data.ExprInfo
addPlan, addPlan, info, planAttr, planElem, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

UNDEF

public static final int UNDEF
Undefined item.

See Also:
Constant Field Values

score

public java.lang.Double score
Score value. null reference takes less memory on 32bit than a double.

Constructor Detail

Item

protected Item(Type t)
Constructor.

Parameters:
t - data type
Method Detail

iter

public final ValueIter iter()
Description copied from class: Value
Returns an iterator.

Specified by:
iter in class Value
Returns:
iterator

item

public final Item item(QueryContext ctx,
                       InputInfo ii)
Description copied from class: Expr
Evaluates the expression and returns the resulting item or a null reference, if the expression yields an empty sequence. If this method is not overwritten, Expr.iter(org.basex.query.QueryContext) must be implemented by an expression, as it may be called by this method.

Specified by:
item in class Expr
Parameters:
ctx - query context
ii - input info
Returns:
iterator

itemAt

public final Item itemAt(long pos)
Description copied from class: Value
Gets the item at the given position in the value.

Specified by:
itemAt in class Value
Parameters:
pos - position
Returns:
item

ebv

public final Item ebv(QueryContext ctx,
                      InputInfo ii)
Description copied from class: Expr
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 numeric predicate.

Specified by:
ebv in class Expr
Parameters:
ctx - query context
ii - input info
Returns:
item

test

public Item test(QueryContext ctx,
                 InputInfo ii)
          throws QueryException
Description copied from class: Expr
Performs a predicate test and returns the item if test was successful.

Specified by:
test in class Expr
Parameters:
ctx - query context
ii - input info
Returns:
item
Throws:
QueryException - query exception

isItem

public final boolean isItem()
Description copied from class: Expr
Tests if this is an item.

Overrides:
isItem in class Expr
Returns:
result of check

string

public abstract byte[] string(InputInfo ii)
                       throws QueryException
Returns a string representation of the value.

Parameters:
ii - input info, use null if none is available
Returns:
string value
Throws:
QueryException - if the item can't be atomized

bool

public boolean bool(InputInfo ii)
             throws QueryException
Returns a boolean representation of the value.

Parameters:
ii - input info
Returns:
boolean value
Throws:
QueryException - query exception

dec

public java.math.BigDecimal dec(InputInfo ii)
                         throws QueryException
Returns a decimal representation of the value.

Parameters:
ii - input info
Returns:
decimal value
Throws:
QueryException - query exception

itr

public long itr(InputInfo ii)
         throws QueryException
Returns an integer (long) representation of the value.

Parameters:
ii - input info
Returns:
long value
Throws:
QueryException - query exception

flt

public float flt(InputInfo ii)
          throws QueryException
Returns a float representation of the value.

Parameters:
ii - input info
Returns:
float value
Throws:
QueryException - query exception

dbl

public double dbl(InputInfo ii)
           throws QueryException
Returns a double representation of the value.

Parameters:
ii - input info
Returns:
double value
Throws:
QueryException - query exception

comparable

public final boolean comparable(Item it)
Checks if the items can be compared.

Parameters:
it - item to be compared
Returns:
result of check

eq

public abstract boolean eq(Item it,
                           Collation coll,
                           InputInfo ii)
                    throws QueryException
Checks the items for equality.

Parameters:
it - item to be compared
coll - collation
ii - input info
Returns:
result of check
Throws:
QueryException - query exception

equiv

public final boolean equiv(Item it,
                           Collation coll,
                           InputInfo ii)
                    throws QueryException
Checks the items for equivalence.

Parameters:
it - item to be compared
coll - collation
ii - input info
Returns:
result of check
Throws:
QueryException - query exception

diff

public int diff(Item it,
                Collation coll,
                InputInfo ii)
         throws QueryException
Returns the difference between the current and the specified item.

Parameters:
it - item to be compared
coll - query context
ii - input info
Returns:
difference
Throws:
QueryException - query exception

input

public BufferInput input(InputInfo ii)
                  throws QueryException
Returns an input stream.

Parameters:
ii - input info
Returns:
input stream
Throws:
QueryException - query exception

materialize

public Item materialize(InputInfo ii)
                 throws QueryException
Materializes streamable values, or returns a self reference.

Parameters:
ii - input info
Returns:
materialized item
Throws:
QueryException - query exception

type

public final SeqType type()
Description copied from class: Expr
Returns the static type of the evaluated value. For simplicity, some types have been merged to super types. As an example, many numeric types are treated as integers.

Specified by:
type in class Expr
Returns:
result of check

size

public final long size()
Description copied from class: Expr
Returns the sequence size or 1.

Specified by:
size in class Value
Returns:
result of check

iterable

public final boolean iterable()
Description copied from class: Expr
Returns true if the expression is iterable, i.e., if it will not contain any duplicate nodes and if all nodes will be are sorted. The return value of this method is only relevant for node sequences. It is e.g. called by AxisPath.

Overrides:
iterable in class Expr
Returns:
result of check

score

public double score()
Returns a score value.

Returns:
score value

score

public final void score(double s)
Sets a new score value.

Parameters:
s - score value

castErr

protected final QueryException castErr(java.lang.Object val,
                                       InputInfo ii)
                                throws QueryException
Throws a cast error.

Parameters:
val - cast value
ii - input info
Returns:
never
Throws:
QueryException - query exception

description

public java.lang.String description()
Description copied from class: ExprInfo
Returns a string description of the expression. This method is only called by error messages. Contrary to the ExprInfo.toString() method, arguments are not included in the output.

Overrides:
description in class Value
Returns:
result of check

plan

public void plan(FElem plan)
Description copied from class: ExprInfo
Creates an expression tree.

Specified by:
plan in class ExprInfo
Parameters:
plan - root element

hash

public int hash(InputInfo ii)
         throws QueryException
Description copied from class: Value
Returns a hash code for this value.

Specified by:
hash in class Value
Parameters:
ii - input info
Returns:
hash code
Throws:
QueryException - if atomization can't be applied (e.g. function item)

writeTo

public final int writeTo(Item[] arr,
                         int start)
Description copied from class: Value
Writes this value's items out to the given array.

Specified by:
writeTo in class Value
Parameters:
arr - array to write to
start - start position
Returns:
number of written items

homogeneous

public final boolean homogeneous()
Description copied from class: Value
Checks if all items of this value share the same type.

Specified by:
homogeneous in class Value
Returns:
result of check

xdmInfo

public byte[] xdmInfo()
Returns data model info.

Returns:
type string

typeId

public Type.ID typeId()
Returns a type id.

Returns:
type string