org.basex.query.item
Class Item

java.lang.Object
  extended by org.basex.query.ExprInfo
      extended by org.basex.query.expr.Expr
          extended by org.basex.query.item.Item
Direct Known Subclasses:
B64, Bln, Date, Dbl, Dec, Dur, Flt, Hex, Itr, Jav, Nod, QNm, Seq, Str

public abstract class Item
extends Expr

Abstract item.

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

Field Summary
 Type type
          Data type.
 
Method Summary
 Item atomic(QueryContext ctx)
          Evaluates the expression and returns the resulting item or a null reference.
 boolean bool()
          Returns a boolean representation of the item.
 void castErr(java.lang.Object val)
          Throws a cast error.
 Expr comp(QueryContext ctx)
          Optimizes and compiles the expression.
 boolean d()
          Checks if this is a duration.
 double dbl()
          Returns a double representation of the item.
 java.math.BigDecimal dec()
          Returns a decimal representation of the item.
 int diff(Item it)
          Returns the difference between the current and the specified item.
 boolean duplicates(QueryContext ctx)
          Returns true if the expression might yield duplicates and unsorted results.
 Item ebv(QueryContext ctx)
          Checks if the iterator can be dissolved into an effective boolean value.
abstract  boolean eq(Item it)
          Checks the items for equality.
 float flt()
          Returns a float representation of the item.
 int hash()
          Returns a hash code.
 boolean i()
          Checks if this is an item.
 Iter iter()
          Returns an item iterator.
 Iter iter(QueryContext ctx)
          Evaluates the expression and returns an iterator on the resulting items.
 long itr()
          Returns an integer (long) representation of the item.
 java.lang.Object java()
          Returns a Java object.
 boolean n()
          Checks if this is a numeric item.
 byte[] name()
          Returns the simplified class name (for debugging).
 boolean node()
          Checks if this is a node.
 void plan(Serializer ser)
          Recursively sends the abstract syntax of this expression to the specified serializer.
 boolean removable(Var v, QueryContext ctx)
          Checks if the specified variable is removable.
 Return returned(QueryContext ctx)
          Indicates the return type of an expression.
 boolean s()
          Checks if this is a string item.
 double score()
          Returns a score value.
 void score(double s)
          Sets a new score value.
 void serialize(Serializer ser)
          Serializes the item.
 byte[] str()
          Returns an atomized string.
 Item test(QueryContext ctx)
          Performs a predicate test and returns the item if test was successful.
 java.lang.String toString()
           
 boolean u()
          Checks if this is an untyped item.
 boolean uses(Expr.Use use, QueryContext ctx)
          Indicates if an expression uses the specified type.
 
Methods inherited from class org.basex.query.expr.Expr
addText, checkCtx, checkDbl, checkItr, e, indexAccessible, indexEquivalent, remove, sameAs, size
 
Methods inherited from class org.basex.query.ExprInfo
color, info
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

type

public Type type
Data type.

Method Detail

comp

public Expr comp(QueryContext ctx)
Description copied from class: Expr
Optimizes and compiles the expression.

Specified by:
comp in class Expr
Parameters:
ctx - query context
Returns:
optimized Expression

iter

public Iter iter(QueryContext ctx)
Description copied from class: Expr
Evaluates the expression and returns an iterator on the resulting items. If this method is not overwritten, Expr.atomic(org.basex.query.QueryContext) must be implemented.

Overrides:
iter in class Expr
Parameters:
ctx - query context
Returns:
resulting item

iter

public Iter iter()
Returns an item iterator.

Returns:
iterator

atomic

public Item atomic(QueryContext ctx)
            throws QueryException
Description copied from class: Expr
Evaluates the expression and returns the resulting item or a null reference. If this method is not overwritten, Expr.iter(org.basex.query.QueryContext) must be implemented.

Overrides:
atomic in class Expr
Parameters:
ctx - query context
Returns:
iterator
Throws:
QueryException - query exception

ebv

public Item ebv(QueryContext ctx)
         throws QueryException
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 position predicate.

Overrides:
ebv in class Expr
Parameters:
ctx - query context
Returns:
item
Throws:
QueryException - query exception

test

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

Overrides:
test in class Expr
Parameters:
ctx - query context
Returns:
item
Throws:
QueryException - evaluation exception

i

public boolean i()
Description copied from class: Expr
Checks if this is an item.

Overrides:
i in class Expr
Returns:
result of check

n

public final boolean n()
Checks if this is a numeric item.

Returns:
result of check

u

public final boolean u()
Checks if this is an untyped item.

Returns:
result of check

s

public final boolean s()
Checks if this is a string item.

Returns:
result of check

d

public final boolean d()
Checks if this is a duration.

Returns:
result of check

node

public final boolean node()
Checks if this is a node.

Returns:
result of check

str

public byte[] str()
Returns an atomized string.

Returns:
string representation

hash

public int hash()
Returns a hash code.

Returns:
hash code

java

public java.lang.Object java()
Returns a Java object.

Returns:
string representation

bool

public boolean bool()
             throws QueryException
Returns a boolean representation of the item.

Returns:
boolean value
Throws:
QueryException - evaluation exception

dec

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

Returns:
decimal value
Throws:
QueryException - evaluation exception

itr

public long itr()
         throws QueryException
Returns an integer (long) representation of the item.

Returns:
long value
Throws:
QueryException - evaluation exception

flt

public float flt()
          throws QueryException
Returns a float representation of the item.

Returns:
float value
Throws:
QueryException - evaluation exception

dbl

public double dbl()
           throws QueryException
Returns a double representation of the item.

Returns:
double value
Throws:
QueryException - evaluation exception

eq

public abstract boolean eq(Item it)
                    throws QueryException
Checks the items for equality.

Parameters:
it - item to be compared.
Returns:
result of check
Throws:
QueryException - evaluation exception

diff

public int diff(Item it)
         throws QueryException
Returns the difference between the current and the specified item.

Parameters:
it - item to be compared.
Returns:
difference
Throws:
QueryException - evaluation exception

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

public final void castErr(java.lang.Object val)
                   throws QueryException
Throws a cast error.

Parameters:
val - cast value
Throws:
QueryException - evaluation exception

serialize

public void serialize(Serializer ser)
               throws java.io.IOException
Serializes the item.

Parameters:
ser - serializer
Throws:
java.io.IOException - exception

uses

public boolean uses(Expr.Use use,
                    QueryContext ctx)
Description copied from class: Expr
Indicates if an expression uses the specified type. Called by the compiler to perform certain optimizations. true is returned by default and thus assumed as "worst-case".

Overrides:
uses in class Expr
Parameters:
use - use type to be checked
ctx - query context
Returns:
result of check

removable

public boolean removable(Var v,
                         QueryContext ctx)
Description copied from class: Expr
Checks if the specified variable is removable.

Overrides:
removable in class Expr
Parameters:
v - variable to be removed
ctx - query context
Returns:
result of check

returned

public Return returned(QueryContext ctx)
Description copied from class: Expr
Indicates the return type of an expression. Called by the compiler to check if expressions can be reformulated. null is returned by default.

Overrides:
returned in class Expr
Parameters:
ctx - query context
Returns:
result of check

duplicates

public boolean duplicates(QueryContext ctx)
Description copied from class: Expr
Returns true if the expression might yield duplicates and unsorted results.

Overrides:
duplicates in class Expr
Parameters:
ctx - query context
Returns:
result of check

name

public final byte[] name()
Description copied from class: ExprInfo
Returns the simplified class name (for debugging).

Overrides:
name in class ExprInfo
Returns:
class name

plan

public void plan(Serializer ser)
          throws java.io.IOException
Description copied from class: ExprInfo
Recursively sends the abstract syntax of this expression to the specified serializer.

Specified by:
plan in class ExprInfo
Parameters:
ser - serializer
Throws:
java.io.IOException - exception

toString

public java.lang.String toString()
Specified by:
toString in class ExprInfo