org.basex.query.xquery.item
Class Item

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

public abstract class Item
extends Expr

Abstract item.

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

Nested Class Summary
 
Nested classes/interfaces inherited from class org.basex.query.xquery.expr.Expr
Expr.Return, Expr.Using
 
Field Summary
 Type type
          Data type.
 
Method Summary
 boolean bool()
          Returns a boolean representation of the item.
 void castErr(java.lang.Object val)
          Throws a cast error.
 Expr comp(XQContext 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.
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(XQContext 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.
 Type returned()
          Indicates if an expression returns the specified type.
 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.
 int size()
          Returns the sequence size or 1.
 byte[] str()
          Returns an atomized string.
 java.lang.String toString()
           
 boolean u()
          Checks if this is an untyped item.
 boolean uses(Expr.Using u)
          Indicates if an expression uses the specified type.
 
Methods inherited from class org.basex.query.xquery.expr.Expr
e
 
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(XQContext ctx)
Description copied from class: Expr
Optimizes and compiles the expression.

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

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

size

public int size()
Returns the sequence size or 1.

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 XQException
Returns a boolean representation of the item.

Returns:
boolean value
Throws:
XQException - evaluation exception

dec

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

Returns:
decimal value
Throws:
XQException - evaluation exception

itr

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

Returns:
long value
Throws:
XQException - evaluation exception

flt

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

Returns:
float value
Throws:
XQException - evaluation exception

dbl

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

Returns:
double value
Throws:
XQException - evaluation exception

iter

public Iter iter(XQContext ctx)
Description copied from class: Expr
Evaluates the expression and returns an iterator on the resulting items.

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

iter

public Iter iter()
Returns an item iterator.

Returns:
iterator

eq

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

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

diff

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

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

score

public double score()
Returns a score value.

Returns:
score value

score

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

Parameters:
s - score value

castErr

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

Parameters:
val - cast value
Throws:
XQException - 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.Using u)
Description copied from class: Expr
Indicates if an expression uses the specified type. Called by the compiler to check if expressions can be reformulated. true is returned by default.

Overrides:
uses in class Expr
Parameters:
u - using flag
Returns:
result of check

returned

public Type returned()
Description copied from class: Expr
Indicates if an expression returns the specified type. Called by the compiler to check if expressions can be reformulated. null is returned by default.

Overrides:
returned in class Expr
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