org.h2.index
Class IndexCondition

java.lang.Object
  extended by org.h2.index.IndexCondition

public class IndexCondition
extends java.lang.Object

A index condition object is made for each condition that can potentially use an index. This class does not extend expression, but in general there is one expression that maps to each index condition.


Field Summary
static int ALWAYS_FALSE
          A bit of a search mask meaning 'the condition is always false'.
static int END
          A bit of a search mask meaning 'smaller or equal'.
static int EQUALITY
          A bit of a search mask meaning 'equal'.
static int RANGE
          A search mask meaning 'between'.
static int START
          A bit of a search mask meaning 'larger or equal'.
 
Method Summary
static IndexCondition get(int compareType, ExpressionColumn column, Expression expression)
          Create an index condition with the given parameters.
 Column getColumn()
          Get the referenced column.
 int getCompareType()
           
 LocalResult getCurrentResult(Session session)
          Get the current result of the expression.
 Value getCurrentValue(Session session)
          Get the current value of the expression.
 Value[] getCurrentValueList(Session session)
          Get the current value list of the expression.
static IndexCondition getInList(ExpressionColumn column, ObjectArray<Expression> list)
          Create an index condition with the compare type IN_LIST and with the given parameters.
static IndexCondition getInQuery(ExpressionColumn column, Query query)
          Create an index condition with the compare type IN_QUERY and with the given parameters.
 int getMask()
          Get the comparison bit mask.
 java.lang.String getSQL()
          Get the SQL snippet of this comparison.
 boolean isAlwaysFalse()
          Check if the result is always false.
 boolean isEnd()
          Check if this index condition is of the type column smaller or equal to value.
 boolean isEvaluatable()
          Check if the expression can be evaluated.
 boolean isStart()
          Check if this index condition is of the type column larger or equal to value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EQUALITY

public static final int EQUALITY
A bit of a search mask meaning 'equal'.

See Also:
Constant Field Values

START

public static final int START
A bit of a search mask meaning 'larger or equal'.

See Also:
Constant Field Values

END

public static final int END
A bit of a search mask meaning 'smaller or equal'.

See Also:
Constant Field Values

RANGE

public static final int RANGE
A search mask meaning 'between'.

See Also:
Constant Field Values

ALWAYS_FALSE

public static final int ALWAYS_FALSE
A bit of a search mask meaning 'the condition is always false'.

See Also:
Constant Field Values
Method Detail

get

public static IndexCondition get(int compareType,
                                 ExpressionColumn column,
                                 Expression expression)
Create an index condition with the given parameters.

Parameters:
compareType - the comparison type
column - the column
expression - the expression
Returns:
the index condition

getInList

public static IndexCondition getInList(ExpressionColumn column,
                                       ObjectArray<Expression> list)
Create an index condition with the compare type IN_LIST and with the given parameters.

Parameters:
column - the column
list - the expression list
Returns:
the index condition

getInQuery

public static IndexCondition getInQuery(ExpressionColumn column,
                                        Query query)
Create an index condition with the compare type IN_QUERY and with the given parameters.

Parameters:
column - the column
query - the select statement
Returns:
the index condition

getCurrentValue

public Value getCurrentValue(Session session)
                      throws java.sql.SQLException
Get the current value of the expression.

Parameters:
session - the session
Returns:
the value
Throws:
java.sql.SQLException

getCurrentValueList

public Value[] getCurrentValueList(Session session)
                            throws java.sql.SQLException
Get the current value list of the expression. The value list is of the same type as the column, distinct, and sorted.

Parameters:
session - the session
Returns:
the value list
Throws:
java.sql.SQLException

getCurrentResult

public LocalResult getCurrentResult(Session session)
                             throws java.sql.SQLException
Get the current result of the expression. The rows may not be of the same type, therefore the rows may not be unique.

Parameters:
session - the session
Returns:
the result
Throws:
java.sql.SQLException

getSQL

public java.lang.String getSQL()
Get the SQL snippet of this comparison.

Returns:
the SQL snippet

getMask

public int getMask()
Get the comparison bit mask.

Returns:
the mask

isAlwaysFalse

public boolean isAlwaysFalse()
Check if the result is always false.

Returns:
true if the result will always be false

isStart

public boolean isStart()
Check if this index condition is of the type column larger or equal to value.

Returns:
true if this is a start condition

isEnd

public boolean isEnd()
Check if this index condition is of the type column smaller or equal to value.

Returns:
true if this is a end condition

getCompareType

public int getCompareType()

getColumn

public Column getColumn()
Get the referenced column.

Returns:
the column

isEvaluatable

public boolean isEvaluatable()
Check if the expression can be evaluated.

Returns:
true if it can be evaluated