com.caucho.db.table
Class Column

java.lang.Object
  extended by com.caucho.db.table.Column

@Module
public abstract class Column
extends java.lang.Object


Nested Class Summary
static class Column.ColumnType
           
 
Field Summary
protected  int _columnOffset
           
protected  byte _nullMask
           
protected  int _nullOffset
           
 
Method Summary
 void close()
          Cleanup of the column on table shutdown.
 void evalToResult(long blockId, byte[] block, int rowOffset, SelectResult result)
          Evaluates the column to the result.
 int getAutoIncrement()
          Set if the column is unique.
 byte[] getBytes(long blockId, byte[] block, int rowOffset)
          Gets a string value from the column.
 long getDate(byte[] block, int rowOffset)
          Gets a double value in the column.
abstract  int getDeclarationSize()
          Returns the column's size (from the decl).
 Expr getDefault()
          Gets the default expression
 double getDouble(long blockId, byte[] block, int rowOffset)
          Sets a double value in the column.
 BTree getIndex()
          Returns the index.
 KeyCompare getIndexKeyCompare()
          Returns the key compare for the column.
 int getInteger(long blockId, byte[] block, int rowOffset)
          Sets an integer value in the column.
 java.lang.Class<?> getJavaType()
          Returns the java type.
 long getLong(long blockId, byte[] block, int rowOffset)
          Sets a long value in the column.
 java.lang.String getName()
          Returns the column's name.
abstract  java.lang.String getString(long blockId, byte[] block, int rowOffset)
          Gets a string value from the column.
 Table getTable()
          Gets the table.
abstract  Column.ColumnType getTypeCode()
          Returns the column's code.
 boolean isEqual(byte[] buffer1, int rowOffset1, byte[] buffer2, int rowOffset2)
          Returns true if the bytes are equal.
 boolean isEqual(byte[] block, int rowOffset, byte[] buffer, int offset, int length)
          Returns true if the bytes are equal.
 boolean isEqual(long blockId, byte[] block, int rowOffset, java.lang.String string)
          Returns true if the string is equal.
 boolean isNotNull()
          Returns true if the column is NOT NULL.
 boolean isNull(byte[] block, int rowOffset)
          Returns true if the column is null.
 boolean isPrimaryKey()
          Returns true if the column is a primary key
 boolean isUnique()
          Returns true if the column is unique.
 boolean isValid(byte[] block, int rowOffset)
          Returns true if the column is valid (i.e.
 void set(DbTransaction xa, TableIterator iter, Expr expr, QueryContext context)
          Sets based on an iterator.
 void setAutoIncrement(int min)
          Returns true if the column is auto increment
 void setDefault(Expr expr)
          Sets the default expression
 void setIndex(BTree index)
          Sets the index.
protected  void setNonNull(byte[] block, int rowOffset)
          Sets the column non-null.
 void setNotNull()
          Set true if the column is NOT NULL.
 void setNull(byte[] block, int rowOffset)
          Sets the column null.
 void setPrimaryKey(boolean primaryKey)
          Returns true if the column is a primary key
 void setUnique()
          Set if the column is unique.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_columnOffset

protected final int _columnOffset

_nullOffset

protected final int _nullOffset

_nullMask

protected final byte _nullMask
Method Detail

getName

public java.lang.String getName()
Returns the column's name.


getTable

public Table getTable()
Gets the table.


getTypeCode

public abstract Column.ColumnType getTypeCode()
Returns the column's code.


getJavaType

public java.lang.Class<?> getJavaType()
Returns the java type.


isPrimaryKey

public boolean isPrimaryKey()
Returns true if the column is a primary key


setPrimaryKey

public void setPrimaryKey(boolean primaryKey)
Returns true if the column is a primary key


isUnique

public boolean isUnique()
Returns true if the column is unique.


setUnique

public void setUnique()
Set if the column is unique.


getIndex

public BTree getIndex()
Returns the index.


setIndex

public void setIndex(BTree index)
Sets the index.


getIndexKeyCompare

public KeyCompare getIndexKeyCompare()
Returns the key compare for the column.


setNotNull

public void setNotNull()
Set true if the column is NOT NULL.


isNotNull

public boolean isNotNull()
Returns true if the column is NOT NULL.


setDefault

public void setDefault(Expr expr)
Sets the default expression


getDefault

public Expr getDefault()
Gets the default expression


setAutoIncrement

public void setAutoIncrement(int min)
Returns true if the column is auto increment


getAutoIncrement

public int getAutoIncrement()
Set if the column is unique.


getDeclarationSize

public abstract int getDeclarationSize()
Returns the column's size (from the decl).


isNull

public boolean isNull(byte[] block,
                      int rowOffset)
Returns true if the column is null.

Parameters:
block - the block's buffer
rowOffset - the offset of the row in the block

setNull

public final void setNull(byte[] block,
                          int rowOffset)
Sets the column null.

Parameters:
block - the block's buffer
rowOffset - the offset of the row in the block

setNonNull

protected final void setNonNull(byte[] block,
                                int rowOffset)
Sets the column non-null.

Parameters:
block - the block's buffer
rowOffset - the offset of the row in the block

getString

public abstract java.lang.String getString(long blockId,
                                           byte[] block,
                                           int rowOffset)
                                    throws java.sql.SQLException
Gets a string value from the column.

Parameters:
block - the block's buffer
rowOffset - the offset of the row in the block
Throws:
java.sql.SQLException

getInteger

public int getInteger(long blockId,
                      byte[] block,
                      int rowOffset)
               throws java.sql.SQLException
Sets an integer value in the column.

Parameters:
block - the block's buffer
rowOffset - the offset of the row in the block
value - the value to store
Throws:
java.sql.SQLException

getLong

public long getLong(long blockId,
                    byte[] block,
                    int rowOffset)
             throws java.sql.SQLException
Sets a long value in the column.

Parameters:
block - the block's buffer
rowOffset - the offset of the row in the block
value - the value to store
Throws:
java.sql.SQLException

getDouble

public double getDouble(long blockId,
                        byte[] block,
                        int rowOffset)
                 throws java.sql.SQLException
Sets a double value in the column.

Parameters:
block - the block's buffer
rowOffset - the offset of the row in the block
value - the value to store
Throws:
java.sql.SQLException

getBytes

public byte[] getBytes(long blockId,
                       byte[] block,
                       int rowOffset)
                throws java.sql.SQLException
Gets a string value from the column.

Parameters:
block - the block's buffer
rowOffset - the offset of the row in the block
Throws:
java.sql.SQLException

getDate

public long getDate(byte[] block,
                    int rowOffset)
             throws java.sql.SQLException
Gets a double value in the column.

Parameters:
block - the block's buffer
rowOffset - the offset of the row in the block
Throws:
java.sql.SQLException

isValid

public boolean isValid(byte[] block,
                       int rowOffset)
Returns true if the column is valid (i.e. not corrupted).

Parameters:
block - the block's buffer
rowOffset - the offset of the row in the block

isEqual

public boolean isEqual(byte[] block,
                       int rowOffset,
                       byte[] buffer,
                       int offset,
                       int length)
Returns true if the bytes are equal.


isEqual

public boolean isEqual(byte[] buffer1,
                       int rowOffset1,
                       byte[] buffer2,
                       int rowOffset2)
Returns true if the bytes are equal.


isEqual

public boolean isEqual(long blockId,
                       byte[] block,
                       int rowOffset,
                       java.lang.String string)
                throws java.sql.SQLException
Returns true if the string is equal.

Throws:
java.sql.SQLException

evalToResult

public void evalToResult(long blockId,
                         byte[] block,
                         int rowOffset,
                         SelectResult result)
                  throws java.sql.SQLException
Evaluates the column to the result.

Throws:
java.sql.SQLException

set

public void set(DbTransaction xa,
                TableIterator iter,
                Expr expr,
                QueryContext context)
         throws java.sql.SQLException
Sets based on an iterator.

Throws:
java.sql.SQLException

close

public void close()
Cleanup of the column on table shutdown.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object