|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.ObjectgeneralDatabase.pamCursor.PamCursor
generalDatabase.pamCursor.NonScrollablePamCursor
public class NonScrollablePamCursor
A wrapper around non scrollable cursors to make them behave in the same way as a scrollable cursor.
When the cursor is opened, all data are fetched into memory buffers and the statement used to fetch the data is closed.
The data consist of arrays of type Object. These can be fetched and scrolled through as though we were using a scrollable cursor working on the database.
Whenever a row is updated, a simpel query which updates that single row get's called.
| Field Summary | |
|---|---|
private PamDataRow |
currentData
reference to current data row - will have to be updated every time the iterator is moved |
private int |
currentRow
current row position, zero indexed. |
private java.util.ListIterator<PamDataRow> |
dataIterator
Iterator over all items in dataRows; |
private java.util.LinkedList<PamDataRow> |
dataRows
linked list of data rows. |
private boolean |
immediate
ACtions such as delete and update take place immediately. |
private PamDataRow |
insertRowData
|
private int |
nCol
|
private int |
nRows
total number of rows read in |
private int |
oldCurrentRow
|
| Constructor Summary | |
|---|---|
NonScrollablePamCursor(EmptyTableDefinition tableDefinition)
|
|
| Method Summary | |
|---|---|
boolean |
absolute(int row)
Go t0 an absolute row number |
private boolean |
addNew()
Add new data with a single prepared statement. |
void |
afterLast()
|
void |
beforeFirst()
|
void |
close()
|
boolean |
closeScrollableCursor()
Close the scrollable cursor. |
void |
deleteRow()
|
private boolean |
deleteUnwanted()
Delete unwanted data with a single statement for all unwanted ID's. |
int |
findColumn(java.lang.String columnLabel)
|
boolean |
first()
|
boolean |
getBoolean(int columnIndex)
|
byte |
getByte(int columnIndex)
|
java.sql.Date |
getDate(int columnIndex)
|
java.sql.Date |
getDate(int columnIndex,
java.util.Calendar cal)
|
double |
getDouble(int columnIndex)
|
float |
getFloat(int columnIndex)
|
int |
getInt(int columnIndex)
|
(package private) int |
getLastDatabaseIndex(java.sql.Connection connection,
java.sql.PreparedStatement preparedInsertStatement)
Gets called from ImmediateInsert to get the last database index using a couple of alternate methods. |
long |
getLong(int columnIndex)
|
java.lang.Object |
getObject(int columnIndex)
|
int |
getRow()
Retrieves the current row number. |
java.sql.RowId |
getRowId(int columnIndex)
|
java.lang.String |
getString(int columnIndex)
|
java.sql.Time |
getTime(int columnIndex)
|
java.sql.Timestamp |
getTimestamp(int columnIndex)
|
private java.sql.Statement |
getUpdateStatement()
|
int |
insertRow(boolean getIndex)
Insert row statement |
boolean |
isAfterLast()
|
boolean |
isBeforeFirst()
|
boolean |
isClosed()
|
boolean |
isFirst()
|
boolean |
isLast()
|
boolean |
last()
|
void |
moveToCurrentRow()
|
void |
moveToInsertRow()
|
boolean |
next()
|
boolean |
openScrollableCursor(java.sql.Connection connection,
boolean includeKeys,
boolean includeCounters,
java.lang.String clause)
Open a scrollable cursor |
boolean |
previous()
|
void |
refreshRow()
|
boolean |
rowDeleted()
|
boolean |
rowInserted()
|
boolean |
rowUpdated()
|
void |
updateBoolean(int columnIndex,
boolean x)
|
void |
updateByte(int columnIndex,
byte x)
|
boolean |
updateDatabase()
Push everything down onto the database |
private boolean |
updateExisting()
Update existing data in the database, i.e. |
void |
updateInt(int columnIndex,
int x)
|
void |
updateLong(int columnIndex,
long x)
|
void |
updateNull(int columnIndex)
|
void |
updateObject(int columnIndex,
java.lang.Object x)
|
void |
updateRow()
|
void |
updateShort(int columnIndex,
short x)
|
private void |
updateSingleRow(PamDataRow currentData2)
|
void |
updateString(int columnIndex,
java.lang.String x)
|
void |
updateTimestamp(int columnIndex,
java.sql.Timestamp x)
|
private boolean |
validRow()
checks the current row is valid, i.e. |
| Methods inherited from class generalDatabase.pamCursor.PamCursor |
|---|
finalize, getCurrentConnection, getInsertString, getSelectString, getSelectString, getTableDefinition, getUpdateString, immediateInsert, immediateUpdate, moveDataToCursor, moveDataToTableDef, openInsertCursor, openReadOnlyCursor, setCurrentConnection |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private java.util.LinkedList<PamDataRow> dataRows
private java.util.ListIterator<PamDataRow> dataIterator
private int nRows
private int currentRow
N.B. The commands coming in to things like absolute will be using 1 indexed (SQL standard) row numbers.
private PamDataRow currentData
private boolean immediate
private int oldCurrentRow
private int nCol
private PamDataRow insertRowData
| Constructor Detail |
|---|
public NonScrollablePamCursor(EmptyTableDefinition tableDefinition)
| Method Detail |
|---|
public boolean openScrollableCursor(java.sql.Connection connection,
boolean includeKeys,
boolean includeCounters,
java.lang.String clause)
PamCursor
openScrollableCursor in class PamCursorconnection - database connectionincludeKeys - include keysincludeCounters - inlcude countersclause - selection and ordering clause.
int getLastDatabaseIndex(java.sql.Connection connection,
java.sql.PreparedStatement preparedInsertStatement)
PamCursor
getLastDatabaseIndex in class PamCursorpublic boolean closeScrollableCursor()
PamCursor
closeScrollableCursor in class PamCursorpublic boolean updateDatabase()
PamCursor
updateDatabase in class PamCursorprivate boolean updateExisting()
private boolean addNew()
private boolean deleteUnwanted()
private void updateSingleRow(PamDataRow currentData2)
private java.sql.Statement getUpdateStatement()
public boolean absolute(int row)
PamCursorNote that row numbers are 1 indexed.
absolute in class PamCursorrow - Row number
public void beforeFirst()
beforeFirst in class PamCursorpublic void afterLast()
afterLast in class PamCursorpublic boolean first()
first in class PamCursorpublic boolean last()
last in class PamCursorpublic boolean next()
next in class PamCursorpublic boolean previous()
previous in class PamCursorprivate boolean validRow()
public void close()
close in class PamCursorpublic void deleteRow()
deleteRow in class PamCursorpublic int findColumn(java.lang.String columnLabel)
findColumn in class PamCursor
public int getRow()
throws java.sql.SQLException
PamCursor
getRow in class PamCursorjava.sql.SQLException - if a database error occurspublic java.lang.Object getObject(int columnIndex)
getObject in class PamCursorpublic boolean getBoolean(int columnIndex)
getBoolean in class PamCursorpublic byte getByte(int columnIndex)
getByte in class PamCursor
public java.sql.Date getDate(int columnIndex,
java.util.Calendar cal)
getDate in class PamCursorpublic java.sql.Date getDate(int columnIndex)
getDate in class PamCursorpublic double getDouble(int columnIndex)
getDouble in class PamCursorpublic float getFloat(int columnIndex)
getFloat in class PamCursorpublic int getInt(int columnIndex)
getInt in class PamCursorpublic long getLong(int columnIndex)
getLong in class PamCursorpublic java.sql.RowId getRowId(int columnIndex)
getRowId in class PamCursorpublic java.lang.String getString(int columnIndex)
getString in class PamCursorpublic java.sql.Time getTime(int columnIndex)
getTime in class PamCursorpublic java.sql.Timestamp getTimestamp(int columnIndex)
getTimestamp in class PamCursorpublic boolean isAfterLast()
isAfterLast in class PamCursorpublic boolean isBeforeFirst()
isBeforeFirst in class PamCursorpublic boolean isClosed()
isClosed in class PamCursorpublic boolean isFirst()
isFirst in class PamCursorpublic boolean isLast()
isLast in class PamCursorpublic void moveToCurrentRow()
moveToCurrentRow in class PamCursorpublic void moveToInsertRow()
moveToInsertRow in class PamCursorpublic int insertRow(boolean getIndex)
PamCursor
insertRow in class PamCursorgetIndex - set true if you want to return the new database index.
Otherwise 0 will be returned.
public void refreshRow()
refreshRow in class PamCursorpublic boolean rowDeleted()
rowDeleted in class PamCursorpublic boolean rowInserted()
rowInserted in class PamCursorpublic boolean rowUpdated()
rowUpdated in class PamCursor
public void updateObject(int columnIndex,
java.lang.Object x)
throws java.sql.SQLException
updateObject in class PamCursorjava.sql.SQLException
public void updateBoolean(int columnIndex,
boolean x)
throws java.sql.SQLException
updateBoolean in class PamCursorjava.sql.SQLException
public void updateByte(int columnIndex,
byte x)
throws java.sql.SQLException
updateByte in class PamCursorjava.sql.SQLException
public void updateInt(int columnIndex,
int x)
throws java.sql.SQLException
updateInt in class PamCursorjava.sql.SQLException
public void updateLong(int columnIndex,
long x)
throws java.sql.SQLException
updateLong in class PamCursorjava.sql.SQLException
public void updateNull(int columnIndex)
throws java.sql.SQLException
updateNull in class PamCursorjava.sql.SQLException
public void updateRow()
throws java.sql.SQLException
updateRow in class PamCursorjava.sql.SQLException
public void updateString(int columnIndex,
java.lang.String x)
throws java.sql.SQLException
updateString in class PamCursorjava.sql.SQLException
public void updateShort(int columnIndex,
short x)
throws java.sql.SQLException
updateShort in class PamCursorjava.sql.SQLException
public void updateTimestamp(int columnIndex,
java.sql.Timestamp x)
throws java.sql.SQLException
updateTimestamp in class PamCursorjava.sql.SQLException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||