org.tmatesoft.sqljet.core.internal.table
Class SqlJetBtreeTable

java.lang.Object
  extended by org.tmatesoft.sqljet.core.internal.table.SqlJetBtreeTable
All Implemented Interfaces:
ISqlJetBtreeTable
Direct Known Subclasses:
SqlJetBtreeDataTable, SqlJetBtreeIndexTable, SqlJetBtreeSchemaTable, SqlJetMapIndexCursor, SqlJetMapTableCursor

public class SqlJetBtreeTable
extends java.lang.Object
implements ISqlJetBtreeTable


Nested Class Summary
protected static class SqlJetBtreeTable.State
           
 
Field Summary
protected  ISqlJetBtree btree
           
protected  boolean index
           
protected  int rootPage
           
protected  boolean write
           
 
Constructor Summary
SqlJetBtreeTable(ISqlJetBtree btree, int rootPage, boolean write, boolean index)
           
 
Method Summary
protected static boolean checkField(ISqlJetBtreeRecord record, int field)
           
 void clear()
           
protected  void clearRecordCache()
           
 void close()
          Close B-Tree table cursor.
 void delete()
           
 boolean eof()
          Check of end of B-Tree table cursor.
 boolean first()
          Go to first record.
 ISqlJetMemoryPointer getBlob(int field)
          Get field's value as BLOB.
protected  ISqlJetBtreeCursor getCursor()
           
 SqlJetEncoding getEncoding()
           
 int getFieldsCount()
          Get count of fields in current record.
 SqlJetValueType getFieldType(int field)
          Get type of field.
 double getFloat(int field)
          Get field's value as real (float).
 long getInteger(int field)
          Get field's value as integer.
protected  SqlJetKeyInfo getKeyInfo()
           
 long getKeySize()
           
 ISqlJetBtreeRecord getRecord()
           
 java.lang.String getString(int field)
          Get field's value as string.
 java.lang.Object getValue(int field)
          Get value as object.
protected  ISqlJetVdbeMem getValueMem(int field)
           
 java.lang.Object[] getValues()
          Get values as objects.
 java.lang.Object getValueUncached(int field)
           
 boolean hasMoved()
          Returns true if cursor has been moved.
 void insert(ISqlJetMemoryPointer pKey, long nKey, ISqlJetMemoryPointer pData, int nData, int nZero, boolean bias)
           
 boolean isNull(int field)
          Check to field has null value.
 boolean last()
          Go to last record.
 void lock()
          Lock B-Tree table cursor's mutex.
 void lockTable(boolean write)
           
 int moveTo(ISqlJetMemoryPointer pKey, long nKey, boolean bias)
           
 long newRowId()
           
 long newRowId(long prev)
          Get a new integer record number (a.k.a "rowid") used as the key to a table.
 boolean next()
          Go to next record.
 boolean popState()
          Restores previously saved state if there any.
 boolean previous()
          Go to previous record.
 void pushState()
          Saves current state of this table and sets it to point to the first record.
 void unlock()
          Unlock B-Tree table cursror's mutex.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

btree

protected ISqlJetBtree btree

rootPage

protected int rootPage

write

protected boolean write

index

protected boolean index
Constructor Detail

SqlJetBtreeTable

public SqlJetBtreeTable(ISqlJetBtree btree,
                        int rootPage,
                        boolean write,
                        boolean index)
                 throws SqlJetException
Parameters:
db -
btree -
rootPage -
write -
index -
Throws:
SqlJetException
Method Detail

getCursor

protected ISqlJetBtreeCursor getCursor()

getKeyInfo

protected SqlJetKeyInfo getKeyInfo()

pushState

public void pushState()
               throws SqlJetException
Description copied from interface: ISqlJetBtreeTable
Saves current state of this table and sets it to point to the first record.

Specified by:
pushState in interface ISqlJetBtreeTable
Throws:
SqlJetException

popState

public boolean popState()
                 throws SqlJetException
Description copied from interface: ISqlJetBtreeTable
Restores previously saved state if there any.

Specified by:
popState in interface ISqlJetBtreeTable
Returns:
Throws:
SqlJetException

close

public void close()
           throws SqlJetException
Description copied from interface: ISqlJetBtreeTable
Close B-Tree table cursor.

Specified by:
close in interface ISqlJetBtreeTable
Throws:
SqlJetException

unlock

public void unlock()
Description copied from interface: ISqlJetBtreeTable
Unlock B-Tree table cursror's mutex.

Specified by:
unlock in interface ISqlJetBtreeTable

lock

public void lock()
          throws SqlJetException
Description copied from interface: ISqlJetBtreeTable
Lock B-Tree table cursor's mutex.

Specified by:
lock in interface ISqlJetBtreeTable
Throws:
SqlJetException

eof

public boolean eof()
            throws SqlJetException
Description copied from interface: ISqlJetBtreeTable
Check of end of B-Tree table cursor.

Specified by:
eof in interface ISqlJetBtreeTable
Returns:
true if there is not more records.
Throws:
SqlJetException

hasMoved

public boolean hasMoved()
                 throws SqlJetException
Description copied from interface: ISqlJetBtreeTable
Returns true if cursor has been moved. Side effect of this is restore position of cursor.

Specified by:
hasMoved in interface ISqlJetBtreeTable
Returns:
Throws:
SqlJetException

first

public boolean first()
              throws SqlJetException
Description copied from interface: ISqlJetBtreeTable
Go to first record.

Specified by:
first in interface ISqlJetBtreeTable
Returns:
true if there is at least one record.
Throws:
SqlJetException

last

public boolean last()
             throws SqlJetException
Description copied from interface: ISqlJetBtreeTable
Go to last record.

Specified by:
last in interface ISqlJetBtreeTable
Returns:
true if there is at least one record.
Throws:
SqlJetException

next

public boolean next()
             throws SqlJetException
Description copied from interface: ISqlJetBtreeTable
Go to next record.

Specified by:
next in interface ISqlJetBtreeTable
Returns:
true if there is at least one record and end of cursor is not reached yet
Throws:
SqlJetException

previous

public boolean previous()
                 throws SqlJetException
Description copied from interface: ISqlJetBtreeTable
Go to previous record.

Specified by:
previous in interface ISqlJetBtreeTable
Returns:
true if there is at least one record and begin of cursor is not reached yet
Throws:
SqlJetException

getRecord

public ISqlJetBtreeRecord getRecord()
                             throws SqlJetException
Specified by:
getRecord in interface ISqlJetBtreeTable
Returns:
Throws:
SqlJetException

lockTable

public void lockTable(boolean write)
Specified by:
lockTable in interface ISqlJetBtreeTable

getEncoding

public SqlJetEncoding getEncoding()
                           throws SqlJetException
Specified by:
getEncoding in interface ISqlJetBtreeTable
Returns:
Throws:
SqlJetException

checkField

protected static boolean checkField(ISqlJetBtreeRecord record,
                                    int field)
                             throws SqlJetException
Throws:
SqlJetException

getValueMem

protected ISqlJetVdbeMem getValueMem(int field)
                              throws SqlJetException
Throws:
SqlJetException

getValue

public java.lang.Object getValue(int field)
                          throws SqlJetException
Description copied from interface: ISqlJetBtreeTable
Get value as object.

Specified by:
getValue in interface ISqlJetBtreeTable
Returns:
Throws:
SqlJetException

getValueUncached

public java.lang.Object getValueUncached(int field)
                                  throws SqlJetException
Throws:
SqlJetException

getFieldsCount

public int getFieldsCount()
                   throws SqlJetException
Description copied from interface: ISqlJetBtreeTable
Get count of fields in current record.

Specified by:
getFieldsCount in interface ISqlJetBtreeTable
Returns:
count of fields
Throws:
SqlJetException

isNull

public boolean isNull(int field)
               throws SqlJetException
Description copied from interface: ISqlJetBtreeTable
Check to field has null value.

Specified by:
isNull in interface ISqlJetBtreeTable
Parameters:
field - number of field begin from zero
Returns:
true if field value is null
Throws:
SqlJetException

getString

public java.lang.String getString(int field)
                           throws SqlJetException
Description copied from interface: ISqlJetBtreeTable
Get field's value as string.

Specified by:
getString in interface ISqlJetBtreeTable
Parameters:
field - number of field begin from zero
Returns:
field's value as string
Throws:
SqlJetException

getInteger

public long getInteger(int field)
                throws SqlJetException
Description copied from interface: ISqlJetBtreeTable
Get field's value as integer.

Specified by:
getInteger in interface ISqlJetBtreeTable
Parameters:
field - number of field begin from zero
Returns:
field's value as integer
Throws:
SqlJetException

getFloat

public double getFloat(int field)
                throws SqlJetException
Description copied from interface: ISqlJetBtreeTable
Get field's value as real (float).

Specified by:
getFloat in interface ISqlJetBtreeTable
Parameters:
field - number of field begin from zero
Returns:
field's value as real
Throws:
SqlJetException

getFieldType

public SqlJetValueType getFieldType(int field)
                             throws SqlJetException
Description copied from interface: ISqlJetBtreeTable
Get type of field.

Specified by:
getFieldType in interface ISqlJetBtreeTable
Parameters:
field - number of field begin from zero
Returns:
type of field
Throws:
SqlJetException

getBlob

public ISqlJetMemoryPointer getBlob(int field)
                             throws SqlJetException
Description copied from interface: ISqlJetBtreeTable
Get field's value as BLOB.

Specified by:
getBlob in interface ISqlJetBtreeTable
Parameters:
field - number of field begin from zero
Returns:
field's value as BLOB
Throws:
SqlJetException

getValues

public java.lang.Object[] getValues()
                             throws SqlJetException
Description copied from interface: ISqlJetBtreeTable
Get values as objects.

Specified by:
getValues in interface ISqlJetBtreeTable
Returns:
Throws:
SqlJetException

newRowId

public long newRowId()
              throws SqlJetException
Specified by:
newRowId in interface ISqlJetBtreeTable
Returns:
Throws:
SqlJetException

newRowId

public long newRowId(long prev)
              throws SqlJetException
Get a new integer record number (a.k.a "rowid") used as the key to a table. The record number is not previously used as a key in the database table that cursor P1 points to. The new record number is written written to register P2. Prev is the largest previously generated record number. No new record numbers are allowed to be less than this value. When this value reaches its maximum, a SQLITE_FULL error is generated. This mechanism is used to help implement the AUTOINCREMENT feature.

Specified by:
newRowId in interface ISqlJetBtreeTable
Parameters:
prev -
Returns:
Throws:
SqlJetException

clearRecordCache

protected void clearRecordCache()

clear

public void clear()
           throws SqlJetException
Specified by:
clear in interface ISqlJetBtreeTable
Throws:
SqlJetException

getKeySize

public long getKeySize()
                throws SqlJetException
Specified by:
getKeySize in interface ISqlJetBtreeTable
Returns:
Throws:
SqlJetException

moveTo

public int moveTo(ISqlJetMemoryPointer pKey,
                  long nKey,
                  boolean bias)
           throws SqlJetException
Specified by:
moveTo in interface ISqlJetBtreeTable
Returns:
Throws:
SqlJetException

insert

public void insert(ISqlJetMemoryPointer pKey,
                   long nKey,
                   ISqlJetMemoryPointer pData,
                   int nData,
                   int nZero,
                   boolean bias)
            throws SqlJetException
Specified by:
insert in interface ISqlJetBtreeTable
Parameters:
object -
rowId -
pData -
remaining -
i -
b -
Throws:
SqlJetException

delete

public void delete()
            throws SqlJetException
Specified by:
delete in interface ISqlJetBtreeTable
Throws:
SqlJetException