com.caucho.db.sql
Class QueryContext

java.lang.Object
  extended by com.caucho.db.sql.QueryContext

@Module
public class QueryContext
extends java.lang.Object

Represents the state of the query at any particular time.


Method Summary
static QueryContext allocate()
          Returns a new query context.
 void clearParameters()
           
 void close()
           
static void free(QueryContext cxt)
           
 java.io.InputStream getBinaryStream(int index)
          Returns the binary stream parameter.
 int getBoolean(int index)
          Returns the boolean parameter.
 byte[] getBuffer()
          Returns the temp buffer.
 byte[] getBytes(int index)
          Returns the binary stream parameter.
 long getDate(int index)
          Returns the date parameter.
 double getDouble(int index)
          Returns the double parameter.
 GeneratedKeysResultSet getGeneratedKeysResultSet()
          Gets the generated keys result set.
 Data getGroupData(int index)
          Returns the indexed group field.
 double getGroupDouble(int index)
          Sets the indexed group field as a double.
 long getGroupLong(int index)
          Sets the indexed group field as a long.
 java.lang.String getGroupString(int index)
          Sets the indexed group field.
 int getLimit()
          The max rows returned in a select
 long getLong(int index)
          Returns the long parameter.
 SelectResult getResult()
          Gets the result set.
 int getRowUpdateCount()
          Returns the number of rows updated.
 java.lang.String getString(int index)
          Returns the string parameter.
 TableIterator[] getTableIterators()
          Returns the table iterator.
 DbTransaction getTransaction()
          Returns the transaction.
 Column.ColumnType getType(int index)
           
 void init(DbTransaction xa, TableIterator[] tableIterators, boolean isReadOnly)
          Initializes the query state.
 void initGroup(int size, boolean[] isGroupByFields)
          Initializes the group.
 boolean isBinaryStream(int index)
           
 boolean isGroupNull(int index)
          Sets the indexed group field.
 boolean isNull(int index)
          Returns the null parameter.
 boolean isReturnGeneratedKeys()
          Set if the query should return the generated keys.
 void lock()
          Lock the blocks.
 void selectGroup()
          Selects the actual group item.
 void setBinaryStream(int index, java.io.InputStream is, int length)
          Set a binary stream parameter.
 void setBoolean(int index, boolean value)
          Set a boolean parameter.
 void setBytes(int index, byte[] bytes)
          Set a binary stream parameter.
 void setDate(int index, long date)
          Returns the date parameter.
 void setDouble(int index, double value)
          Set a double parameter.
 void setGroupDouble(int index, double value)
          Sets the indexed group field as a double.
 void setGroupLong(int index, long value)
          Sets the indexed group field as a long.
 void setGroupString(int index, java.lang.String value)
          Sets the indexed group field.
 void setLimit(int limit)
          The max rows returned in a select
 void setLong(int index, long value)
          Set a long parameter.
 void setNonLocking()
           
 void setNull(int index)
          Set a null parameter.
 void setResult(SelectResult result)
          Sets the result set.
 void setReturnGeneratedKeys(boolean isReturnGeneratedKeys)
          Set if the query should return the generated keys.
 void setRowUpdateCount(int count)
          Sets the number of rows updated.
 void setString(int index, java.lang.String value)
          Set a string parameter.
 void setTransaction(DbTransaction xa)
          Sets the transaction.
 void unlock()
          Unlock the blocks.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

allocate

public static QueryContext allocate()
Returns a new query context.


setNonLocking

public void setNonLocking()

clearParameters

public void clearParameters()

init

public void init(DbTransaction xa,
                 TableIterator[] tableIterators,
                 boolean isReadOnly)
Initializes the query state.


initGroup

public void initGroup(int size,
                      boolean[] isGroupByFields)
Initializes the group.


selectGroup

public void selectGroup()
Selects the actual group item.


getTableIterators

public TableIterator[] getTableIterators()
Returns the table iterator.


setTransaction

public void setTransaction(DbTransaction xa)
Sets the transaction.


getTransaction

public DbTransaction getTransaction()
Returns the transaction.


getBuffer

public byte[] getBuffer()
Returns the temp buffer.


getRowUpdateCount

public int getRowUpdateCount()
Returns the number of rows updated.


setRowUpdateCount

public void setRowUpdateCount(int count)
Sets the number of rows updated.


isReturnGeneratedKeys

public boolean isReturnGeneratedKeys()
Set if the query should return the generated keys.


setReturnGeneratedKeys

public void setReturnGeneratedKeys(boolean isReturnGeneratedKeys)
Set if the query should return the generated keys.


setLimit

public void setLimit(int limit)
The max rows returned in a select


getLimit

public int getLimit()
The max rows returned in a select


isGroupNull

public boolean isGroupNull(int index)
Sets the indexed group field.


setGroupString

public void setGroupString(int index,
                           java.lang.String value)
Sets the indexed group field.


getGroupString

public java.lang.String getGroupString(int index)
Sets the indexed group field.


setGroupLong

public void setGroupLong(int index,
                         long value)
Sets the indexed group field as a long.


getGroupLong

public long getGroupLong(int index)
Sets the indexed group field as a long.


setGroupDouble

public void setGroupDouble(int index,
                           double value)
Sets the indexed group field as a double.


getGroupDouble

public double getGroupDouble(int index)
Sets the indexed group field as a double.


getGroupData

public Data getGroupData(int index)
Returns the indexed group field.


setNull

public void setNull(int index)
Set a null parameter.


isNull

public boolean isNull(int index)
Returns the null parameter.


setLong

public void setLong(int index,
                    long value)
Set a long parameter.


getBoolean

public int getBoolean(int index)
Returns the boolean parameter.


setBoolean

public void setBoolean(int index,
                       boolean value)
Set a boolean parameter.


getLong

public long getLong(int index)
Returns the long parameter.


getDate

public long getDate(int index)
Returns the date parameter.


setDate

public void setDate(int index,
                    long date)
Returns the date parameter.


setDouble

public void setDouble(int index,
                      double value)
Set a double parameter.


getDouble

public double getDouble(int index)
Returns the double parameter.


setString

public void setString(int index,
                      java.lang.String value)
Set a string parameter.


getString

public java.lang.String getString(int index)
Returns the string parameter.


isBinaryStream

public boolean isBinaryStream(int index)

setBinaryStream

public void setBinaryStream(int index,
                            java.io.InputStream is,
                            int length)
Set a binary stream parameter.


getBinaryStream

public java.io.InputStream getBinaryStream(int index)
Returns the binary stream parameter.


setBytes

public void setBytes(int index,
                     byte[] bytes)
Set a binary stream parameter.


getBytes

public byte[] getBytes(int index)
Returns the binary stream parameter.


getType

public Column.ColumnType getType(int index)

setResult

public void setResult(SelectResult result)
Sets the result set.


getResult

public SelectResult getResult()
Gets the result set.


getGeneratedKeysResultSet

public GeneratedKeysResultSet getGeneratedKeysResultSet()
Gets the generated keys result set.


lock

public void lock()
          throws java.sql.SQLException
Lock the blocks. The blocks are locked in ascending block id order to avoid deadlocks.

Parameters:
isWrite - if true, the block should be locked for writing
Throws:
java.sql.SQLException

unlock

public void unlock()
            throws java.sql.SQLException
Unlock the blocks. The blocks are unlocked in descending order.

Parameters:
isWrite - if true, the block should be unlocked for writing
Throws:
java.sql.SQLException

close

public void close()
           throws java.sql.SQLException
Throws:
java.sql.SQLException

free

public static void free(QueryContext cxt)