|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.tentackle.db.SimpleDbCursor<T>
T - the database object classpublic class SimpleDbCursor<T extends DbObject>
A simple implementation of a DbCursor.
The cursor operates on a ResultSetWrapper for local connections
and on a RemoteDbCursor for remote connections to an
application server.
| Field Summary | |
|---|---|
protected Db |
db
|
protected Class<T> |
dbClass
|
protected T |
object
|
protected RemoteDbCursor |
rc
|
protected String |
rcName
|
protected int |
row
|
protected int |
rows
|
protected ResultSetWrapper |
rs
|
protected boolean |
withLinkedObjects
|
| Constructor Summary | |
|---|---|
SimpleDbCursor(Db db,
Class<T> dbClass,
ResultSetWrapper rs)
Creates a cursor on a result set for local connections. |
|
SimpleDbCursor(Db db,
Class<T> dbClass,
ResultSetWrapper rs,
boolean withLinkedObjects)
Creates a cursor. |
|
SimpleDbCursor(Db db,
RemoteDbCursor rc)
Creates a remote Cursor on the client-side for remote connections. |
|
| Method Summary | |
|---|---|
void |
afterLast()
Positions the cursor after the last row. |
void |
beforeFirst()
Positions the cursor before the first row. |
void |
close()
Closes the cursor. The cursor is opened in its constructor. |
boolean |
deleteObject()
Removes the object of the current row from the cursor and the server. |
boolean |
deleteObjectAt(int row)
Removes the object a given row from the cursor and the server. |
List<T> |
fetch()
Fetches the next objects up to the fetchsize. |
protected void |
finalize()
Overridden to close forgotten cursors. |
boolean |
first()
Rewinds the cursor to the first row. |
Class |
getDbClass()
Gets the class of the objects in the cursor. |
int |
getFetchDirection()
Gets the fetch direction. |
int |
getFetchSize()
Gets the fetchsize. |
T |
getObject()
Gets the data object of the current row. |
T |
getObjectAt(int row)
Gets an the object at a given row. |
int |
getRow()
Gets the current row. |
int |
getRowCount()
Gets the number of rows. Caution: depending on the implementation this method will have to read all data from the server in order to count the rows. |
boolean |
isAfterLast()
Checks whether the cursor is after the last row. |
boolean |
isBeforeFirst()
Checks whether the cursor is before the first row. |
boolean |
isOpen()
Checks whether cursor is open. |
boolean |
isRemote()
Gets the local/remote type of the cursor. |
boolean |
last()
Positions the cursor on the last row. |
T |
newObject()
Creates a new object. |
boolean |
next()
Moves the cursor to the next row. |
boolean |
previous()
Moves the cursor to the previous row. |
void |
setDbContext(T object)
Sets the db-context for objects retrieved from the remote cursor. |
void |
setFetchDirection(int direction)
Sets the fetch direction. |
void |
setFetchSize(int rows)
Sets the fetchsize. |
boolean |
setRow(int row)
Sets the cursor to a given row. |
List<T> |
toList()
Returns the objects of this cursor as a list. |
List<T> |
toListAndClose()
Returns the objects of this cursor as a list and closes this cursor. |
String |
toString()
Returns a string representation of the object. |
void |
updateDbContext(T object)
Updates the db context in the object after the object has been loaded. |
boolean |
updateObject(T object)
Updates the data object of the current row and persist the change to the server. |
boolean |
updateObjectAt(T object,
int row)
Updates the data object at a given row and persist the change to the server. |
boolean |
updateObjectOnly(T object)
Updates the data object of the current row. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected Db db
protected Class<T extends DbObject> dbClass
protected ResultSetWrapper rs
protected RemoteDbCursor rc
protected String rcName
protected boolean withLinkedObjects
protected int row
protected int rows
protected T extends DbObject object
| Constructor Detail |
|---|
public SimpleDbCursor(Db db,
Class<T> dbClass,
ResultSetWrapper rs,
boolean withLinkedObjects)
db - the db connectiondbClass - the DbObject classrs - the resultsetwithLinkedObjects - true if load linked objects, false otherwise
public SimpleDbCursor(Db db,
Class<T> dbClass,
ResultSetWrapper rs)
db - the db connectiondbClass - the DbObject classrs - the resultset
public SimpleDbCursor(Db db,
RemoteDbCursor rc)
db - the remote db connectionrc - the remote cursor| Method Detail |
|---|
public boolean isRemote()
public void close()
close in interface DbCursor<T extends DbObject>public boolean isOpen()
protected void finalize()
throws Throwable
finalize in class ObjectThrowable - the Exception raised by this methodpublic String toString()
java.lang.ObjecttoString method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
toString in class Objectpublic int getRowCount()
The implementation will move to the end of the cursor to determine the number of rows, if not known yet. Subsequent invocations will use the cached value.
getRowCount in interface DbCursor<T extends DbObject>public int getRow()
getRow in interface DbCursor<T extends DbObject>public boolean setRow(int row)
setRow in interface DbCursor<T extends DbObject>row - the row number (must be > 0)
public boolean first()
first in interface DbCursor<T extends DbObject>public boolean last()
last in interface DbCursor<T extends DbObject>public boolean next()
next in interface DbCursor<T extends DbObject>public boolean previous()
previous in interface DbCursor<T extends DbObject>public void beforeFirst()
beforeFirst in interface DbCursor<T extends DbObject>public void afterLast()
afterLast in interface DbCursor<T extends DbObject>public boolean isBeforeFirst()
isBeforeFirst in interface DbCursor<T extends DbObject>public boolean isAfterLast()
isAfterLast in interface DbCursor<T extends DbObject>public T newObject()
public void setDbContext(T object)
object - the DbObject to set the db for, never nullpublic void updateDbContext(T object)
object - the DbObject to update the context for, never nullpublic T getObject()
The remote server may refuse the delivery of the object due to security constraints. In this case, null is returned.
getObject in interface DbCursor<T extends DbObject>public boolean updateObjectOnly(T object)
updateObjectOnly in interface DbCursor<T extends DbObject>object - the data object
public boolean updateObject(T object)
updateObject in interface DbCursor<T extends DbObject>object - the data object
public boolean deleteObject()
deleteObject in interface DbCursor<T extends DbObject>public T getObjectAt(int row)
getObjectAt in interface DbCursor<T extends DbObject>row - the row starting at 1
public boolean updateObjectAt(T object,
int row)
updateObjectAt in interface DbCursor<T extends DbObject>object - the data objectrow - the row starting at 1
public boolean deleteObjectAt(int row)
deleteObjectAt in interface DbCursor<T extends DbObject>row - the row starting at 1
public List<T> toList()
toList in interface DbCursor<T extends DbObject>public List<T> toListAndClose()
toListAndClose in interface DbCursor<T extends DbObject>public Class getDbClass()
getDbClass in interface DbCursor<T extends DbObject>public void setFetchSize(int rows)
setFetchSize in interface DbCursor<T extends DbObject>rows - the fetchsizepublic int getFetchSize()
getFetchSize in interface DbCursor<T extends DbObject>public void setFetchDirection(int direction)
setFetchDirection in interface DbCursor<T extends DbObject>direction - the direction, see ResultSet.setFetchDirection(int).public int getFetchDirection()
getFetchDirection in interface DbCursor<T extends DbObject>public List<T> fetch()
If the fetchsize is 0 (auto), the method will fall back to toList. After having read the last row the cursor is closed! This saves two roundtrips for remote dbs.
fetch in interface DbCursor<T extends DbObject>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||