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-10, ISC License, Christian Gruen

Nested Class Summary
 
Nested classes/interfaces inherited from class org.basex.query.expr.Expr
Expr.Use
 
Field Summary
 double score
          Score value.
 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.
 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.
 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 hashCode()
           
 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.
 Object java()
          Returns a Java object.
 boolean n()
          Checks if this is a numeric item.
 String name()
          Returns the simplified class name.
 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.
 long size(QueryContext ctx)
          Returns the sequence size or 1.
 byte[] str()
          Returns an atomized string.
 Item test(QueryContext ctx)
          Performs a predicate test and returns the item if test was successful.
 String toString()
           
 boolean u()
          Checks if this is an untyped item.
 boolean uses(Expr.Use u, 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, v
 
Methods inherited from class org.basex.query.ExprInfo
color, info
 
Methods inherited from class java.lang.Object
equals, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

score

public double score
Score value.


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 - query 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

size

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

Overrides:
size in class Expr
Parameters:
ctx - query context
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

java

public 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 - query exception

dec

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

Returns:
decimal value
Throws:
QueryException - query exception

itr

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

Returns:
long value
Throws:
QueryException - query exception

flt

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

Returns:
float value
Throws:
QueryException - query exception

dbl

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

Returns:
double value
Throws:
QueryException - query 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 - query 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 - query 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

serialize

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

Parameters:
ser - serializer
Throws:
IOException - I/O exception

uses

public boolean uses(Expr.Use u,
                    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".

Specified by:
uses in class Expr
Parameters:
u - 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 String name()
Description copied from class: ExprInfo
Returns the simplified class name.

Overrides:
name in class ExprInfo
Returns:
class name

plan

public void plan(Serializer ser)
          throws 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:
IOException - I/O exception

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Specified by:
toString in class ExprInfo