|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.mathema.pride.ResultIterator
public class ResultIterator
Helper class to iterate thru a list of results from a query.
ResultIterators are initialized be the Database
class
and provide their results step-by-step in the same Entity
object. A typical usage may look like this:
try { Person p = new Person(); ResultIterator iter = p.queryAll(); do { System.println(p.getName()); } while(iter.next()); } catch(NoResultsException nrx) {}
Field Summary | |
---|---|
static int |
COLUMN_STARTINDEX
|
protected java.sql.Connection |
connection
|
protected Database |
db
|
protected java.lang.Object |
obj
|
protected RecordDescriptor |
red
|
protected java.sql.ResultSet |
results
|
static java.lang.String |
REVISION_ID
|
protected java.sql.Statement |
statement
|
Constructor Summary | |
---|---|
ResultIterator(java.sql.Statement statement,
java.sql.ResultSet rs,
Database db,
java.sql.Connection con)
|
|
ResultIterator(java.sql.Statement statement,
java.sql.ResultSet rs,
java.lang.Object obj,
RecordDescriptor red,
Database db,
java.sql.Connection con)
Creates a new ResultIterator from an query. |
Method Summary | |
---|---|
void |
close()
Closes the iteration by closing the result set, the statement and the database connection passed in the constructor. |
java.math.BigDecimal |
getBigDecimal(int index)
|
java.math.BigDecimal |
getBigDecimal(java.lang.String column)
|
java.sql.Date |
getDate(int index)
|
int |
getFetchSize()
Returns the current fetch size for the underlying ResultSet |
int |
getInt(int index)
|
java.lang.Object |
getObject()
Returns the object, the ResultIterator writes its data to |
java.sql.ResultSet |
getResultSet()
Returns the result set, the iterator is operating on. |
boolean |
isClosed()
Returns true if this result iterator has been closed. |
boolean |
next()
Fetches the next record from the result set and stores it in the entity object passed in the constructor. |
void |
setFetchSize(int size)
Sets the fetch size for the underlying ResultSet |
java.lang.Object[] |
toArray()
Like the function above but returns all data without limitation. |
java.lang.Object[] |
toArray(long maxResults)
Like toArrayList(long) but returns the data as an array. |
java.util.ArrayList |
toArrayList()
Like the function above but returns all data without size limitation. |
java.util.ArrayList |
toArrayList(long maxResults)
Iterates through the complete result set and returns the data in an ArrayList. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int COLUMN_STARTINDEX
protected java.sql.Statement statement
protected java.sql.Connection connection
protected java.sql.ResultSet results
protected java.lang.Object obj
protected RecordDescriptor red
protected Database db
public static final java.lang.String REVISION_ID
Constructor Detail |
---|
public ResultIterator(java.sql.Statement statement, java.sql.ResultSet rs, java.lang.Object obj, RecordDescriptor red, Database db, java.sql.Connection con)
public ResultIterator(java.sql.Statement statement, java.sql.ResultSet rs, Database db, java.sql.Connection con)
Method Detail |
---|
public java.sql.ResultSet getResultSet()
public void close() throws java.sql.SQLException
java.sql.SQLException
public boolean isClosed()
public boolean next() throws java.sql.SQLException
java.sql.SQLException
- if accessing the query results fails
{@link
- NoResultsException} if the iterator is already closedpublic java.lang.Object getObject()
public java.util.ArrayList toArrayList(long maxResults) throws java.sql.SQLException
maxResults
- The maximum number of results to collect. If maxResults is -1,
the function returns all data from the underlying result set
java.lang.CloneNotSupportedException
- if the operation object has no public clone
method available
java.sql.SQLException
- if there occurs a databaes error during iterationpublic java.util.ArrayList toArrayList() throws java.sql.SQLException
java.sql.SQLException
public java.lang.Object[] toArray(long maxResults) throws java.sql.SQLException
toArrayList(long)
but returns the data as an array. The runtime type
of the array's elements is the one of the iterator's operation object.
java.sql.SQLException
public java.lang.Object[] toArray() throws java.sql.SQLException
java.sql.SQLException
public int getFetchSize() throws java.sql.SQLException
java.sql.SQLException
public void setFetchSize(int size) throws java.sql.SQLException
java.sql.SQLException
public int getInt(int index) throws java.sql.SQLException
java.sql.SQLException
public java.math.BigDecimal getBigDecimal(int index) throws java.sql.SQLException
java.sql.SQLException
public java.math.BigDecimal getBigDecimal(java.lang.String column) throws java.sql.SQLException
java.sql.SQLException
public java.sql.Date getDate(int index) throws java.sql.SQLException
java.sql.SQLException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |