org.basex.query.value.seq
Class Empty

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.seq.Empty
All Implemented Interfaces:
java.lang.Iterable<Item>

public final class Empty
extends Value

Empty sequence.

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
static ValueIter ITER
          Empty iterator.
static Empty SEQ
          Single instance.
 
Fields inherited from class org.basex.query.value.Value
type
 
Method Summary
 java.lang.String description()
          Returns a string description of the expression.
 Item ebv(QueryContext ctx, InputInfo ii)
          Checks if the iterator can be dissolved into an effective boolean 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.
 boolean isEmpty()
          Tests if this is an empty sequence.
 boolean isVacuous()
          Tests if this is a vacuous expression (empty sequence or error function).
 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.
 void plan(FElem plan)
          Creates an expression tree.
 long size()
          Returns the sequence size or 1.
 Item test(QueryContext ctx, InputInfo ii)
          Performs a predicate test and returns the item if test was successful.
 java.lang.Object toJava()
          Returns a Java representation of the value.
 java.lang.String toString()
           
 SeqType type()
          Returns the static type of the evaluated value.
 int writeTo(Item[] arr, int start)
          Writes this value's items out to the given array.
 
Methods inherited from class org.basex.query.value.Value
accept, cache, checkUp, compile, copy, count, data, exprSize, has, inline, isValue, iter, iterator, removable, serialize, value
 
Methods inherited from class org.basex.query.expr.Expr
addText, compEbv, copy, hasFreeVars, indexAccessible, indexEquivalent, inlineAll, isFunction, isItem, markTailCalls, optimize, sameAs, uses, visitAll
 
Methods inherited from class org.basex.data.ExprInfo
addPlan, addPlan, info, planAttr, planElem
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SEQ

public static final Empty SEQ
Single instance.


ITER

public static final ValueIter ITER
Empty iterator.

Method Detail

isEmpty

public boolean isEmpty()
Description copied from class: Expr
Tests if this is an empty sequence. This function is only overwritten by the Empty class, which represents the empty sequence.

Overrides:
isEmpty in class Expr
Returns:
result of check

isVacuous

public boolean isVacuous()
Description copied from class: Expr
Tests if this is a vacuous expression (empty sequence or error function). This check is needed for updating queries.

Overrides:
isVacuous in class Expr
Returns:
result of check

size

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

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

toJava

public java.lang.Object toJava()
Description copied from class: Value
Returns a Java representation of the value.

Specified by:
toJava in class Value
Returns:
Java object

iter

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

Specified by:
iter in class Value
Returns:
iterator

item

public 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

ebv

public 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)
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

type

public 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

iterable

public 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

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

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

toString

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

writeTo

public 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

itemAt

public 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

homogeneous

public 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