/** * PUBLIC: * Moves the cursor to the front of the result set, just before the first row */ public void beforeFirst() throws DatabaseException { clearNextAndPrevious(); try { this.resultSet.beforeFirst(); setPosition(0); } catch (SQLException exception) { DatabaseException commException = getAccessor().processExceptionForCommError(this.session, exception, null); if (commException != null) throw commException; throw DatabaseException.sqlException(exception, getAccessor(), this.session, false); } }
/** * PUBLIC: * Moves the cursor to the front of the result set, just before the first row */ public void beforeFirst() throws DatabaseException { clearNextAndPrevious(); try { this.resultSet.beforeFirst(); setPosition(0); } catch (SQLException exception) { DatabaseException commException = getAccessor().processExceptionForCommError(this.session, exception, null); if (commException != null) throw commException; throw DatabaseException.sqlException(exception, getAccessor(), this.session, false); } }
/** * PUBLIC: * Indicates whether the cursor is after the last row in the result set. */ public boolean isAfterLast() throws DatabaseException { try { if (this.nextObject != null) { return false; } if ((this.objectCollection.size() > 0) && (getPosition() <= this.objectCollection.size())) { return false; } return this.resultSet.isAfterLast(); } catch (SQLException exception) { DatabaseException commException = getAccessor().processExceptionForCommError(this.session, exception, null); if (commException != null) throw commException; throw DatabaseException.sqlException(exception, getAccessor(), this.session, false); } }
/** * PUBLIC: * Indicates whether the cursor is after the last row in the result set. */ public boolean isAfterLast() throws DatabaseException { try { if (this.nextObject != null) { return false; } if ((this.objectCollection.size() > 0) && (getPosition() <= this.objectCollection.size())) { return false; } return this.resultSet.isAfterLast(); } catch (SQLException exception) { DatabaseException commException = getAccessor().processExceptionForCommError(this.session, exception, null); if (commException != null) throw commException; throw DatabaseException.sqlException(exception, getAccessor(), this.session, false); } }
/** * PUBLIC: * Retrieves the current cursor position (current row). The first row is number 1, the second number 2, and so on. * Unlike java.sql.ResultSet.getRow(), 0 is not returned if afterLast. * Instead size() + 1 is returned. * @return the current row number; 0 if there is no current row * @exception DatabaseException if a database access error occurs */ public int getPosition() throws DatabaseException { try { if (this.position == -1) { this.position = this.resultSet.getRow(); if (this.position == 0) { // This could mean either beforeFirst or afterLast! if (isAfterLast()) { this.position = size() + 1; } } else { this.position += this.objectCollection.size(); } } return this.position; } catch (SQLException exception) { DatabaseException commException = getAccessor().processExceptionForCommError(this.session, exception, null); if (commException != null) throw commException; throw DatabaseException.sqlException(exception, getAccessor(), this.session, false); } }
/** * PUBLIC: * Moves the cursor to the first row in the result set */ public boolean first() throws DatabaseException { clearNextAndPrevious(); try { if (this.objectCollection.size() > 0) { setPosition(1); this.resultSet.beforeFirst(); return true; } else { return this.resultSet.first(); } } catch (SQLException exception) { DatabaseException commException = getAccessor().processExceptionForCommError(this.session, exception, null); if (commException != null) throw commException; throw DatabaseException.sqlException(exception, getAccessor(), this.session, false); } }
/** * PUBLIC: * Moves the cursor to the last row in the result set */ public boolean last() throws DatabaseException { clearNextAndPrevious(); try { boolean isLast = this.resultSet.last(); if (!isLast) { // cursor must be empty. if (this.objectCollection.size() > 0) { setPosition(this.objectCollection.size()); isLast = true; } } else { setSize(this.objectCollection.size() + this.resultSet.getRow()); setPosition(size); } return isLast; } catch (SQLException exception) { DatabaseException commException = getAccessor().processExceptionForCommError(this.session, exception, null); if (commException != null) throw commException; throw DatabaseException.sqlException(exception, getAccessor(), this.session, false); } }
/** * PUBLIC: * Indicates whether the cursor is on the first row of the result set. */ public boolean isFirst() throws DatabaseException { if (getPreviousObject() != null) { return false; } try { if (this.objectCollection.size() > 0) { return getPosition() == 1; } return this.resultSet.isFirst(); } catch (SQLException exception) { DatabaseException commException = getAccessor().processExceptionForCommError(this.session, exception, null); if (commException != null) throw commException; throw DatabaseException.sqlException(exception, getAccessor(), this.session, false); } }
/** * PUBLIC: * Indicates whether the cursor is on the first row of the result set. */ public boolean isFirst() throws DatabaseException { if (getPreviousObject() != null) { return false; } try { if (this.objectCollection.size() > 0) { return getPosition() == 1; } return this.resultSet.isFirst(); } catch (SQLException exception) { DatabaseException commException = getAccessor().processExceptionForCommError(this.session, exception, null); if (commException != null) throw commException; throw DatabaseException.sqlException(exception, getAccessor(), this.session, false); } }
/** * PUBLIC: * Moves the cursor to the first row in the result set */ public boolean first() throws DatabaseException { clearNextAndPrevious(); try { if (this.objectCollection.size() > 0) { setPosition(1); this.resultSet.beforeFirst(); return true; } else { return this.resultSet.first(); } } catch (SQLException exception) { DatabaseException commException = getAccessor().processExceptionForCommError(this.session, exception, null); if (commException != null) throw commException; throw DatabaseException.sqlException(exception, getAccessor(), this.session, false); } }
/** * PUBLIC: * Moves the cursor to the last row in the result set */ public boolean last() throws DatabaseException { clearNextAndPrevious(); try { boolean isLast = this.resultSet.last(); if (!isLast) { // cursor must be empty. if (this.objectCollection.size() > 0) { setPosition(this.objectCollection.size()); isLast = true; } } else { setSize(this.objectCollection.size() + this.resultSet.getRow()); setPosition(size); } return isLast; } catch (SQLException exception) { DatabaseException commException = getAccessor().processExceptionForCommError(this.session, exception, null); if (commException != null) throw commException; throw DatabaseException.sqlException(exception, getAccessor(), this.session, false); } }
/** * PUBLIC: * Moves the cursor to the end of the result set, just after the last row. */ public void afterLast() throws DatabaseException { clearNextAndPrevious(); try { this.resultSet.afterLast(); setPosition(size() + 1); } catch (SQLException exception) { DatabaseException commException = getAccessor().processExceptionForCommError(this.session, exception, null); if (commException != null) throw commException; throw DatabaseException.sqlException(exception, getAccessor(), this.session, false); } }
/** * PUBLIC: * Moves the cursor to the front of the result set, just before the first row */ public void beforeFirst() throws DatabaseException { clearNextAndPrevious(); try { getResultSet().beforeFirst(); setPosition(0); } catch (SQLException exception) { DatabaseException commException = getAccessor().processExceptionForCommError(getSession(), exception, null); if (commException != null) throw commException; throw DatabaseException.sqlException(exception, getAccessor(), getSession(), false); } }
/** * PUBLIC: * Moves the cursor to the end of the result set, just after the last row. */ public void afterLast() throws DatabaseException { clearNextAndPrevious(); try { this.resultSet.afterLast(); setPosition(size() + 1); } catch (SQLException exception) { DatabaseException commException = getAccessor().processExceptionForCommError(this.session, exception, null); if (commException != null) throw commException; throw DatabaseException.sqlException(exception, getAccessor(), this.session, false); } }
/** * PUBLIC: * Retrieves the current cursor position (current row). The first row is number 1, the second number 2, and so on. * Unlike java.sql.ResultSet.getRow(), 0 is not returned if afterLast. * Instead size() + 1 is returned. * @return the current row number; 0 if there is no current row * @exception SQLException if a database access error occurs */ public int getPosition() throws DatabaseException { try { if (position == -1) { position = getResultSet().getRow(); if (position == 0) { // This could mean either beforeFirst or afterLast! if (isAfterLast()) { position = size() + 1; } } else { position += getObjectCollection().size(); } } return position; } catch (SQLException exception) { DatabaseException commException = getAccessor().processExceptionForCommError(getSession(), exception, null); if (commException != null) throw commException; throw DatabaseException.sqlException(exception, getAccessor(), getSession(), false); } }
/** * PUBLIC: * Indicates whether the cursor is after the last row in the result set. */ public boolean isAfterLast() throws DatabaseException { try { if (getNextObject() != null) { return false; } if ((getObjectCollection().size() > 0) && (getPosition() <= getObjectCollection().size())) { return false; } return getResultSet().isAfterLast(); } catch (SQLException exception) { DatabaseException commException = getAccessor().processExceptionForCommError(getSession(), exception, null); if (commException != null) throw commException; throw DatabaseException.sqlException(exception, getAccessor(), getSession(), false); } }
/** * PUBLIC: * Moves the cursor to the last row in the result set */ public boolean last() throws DatabaseException { clearNextAndPrevious(); try { boolean isLast = getResultSet().last(); if (!isLast) { // cursor must be empty. if (getObjectCollection().size() > 0) { setPosition(getObjectCollection().size()); isLast = true; } } else { setSize(getObjectCollection().size() + getResultSet().getRow()); setPosition(size); } return isLast; } catch (SQLException exception) { DatabaseException commException = getAccessor().processExceptionForCommError(getSession(), exception, null); if (commException != null) throw commException; throw DatabaseException.sqlException(exception, getAccessor(), getSession(), false); } }
/** * PUBLIC: * Moves the cursor to the first row in the result set */ public boolean first() throws DatabaseException { clearNextAndPrevious(); try { if (getObjectCollection().size() > 0) { setPosition(1); getResultSet().beforeFirst(); return true; } else { return getResultSet().first(); } } catch (SQLException exception) { DatabaseException commException = getAccessor().processExceptionForCommError(getSession(), exception, null); if (commException != null) throw commException; throw DatabaseException.sqlException(exception, getAccessor(), getSession(), false); } }
/** * PUBLIC: * Indicates whether the cursor is on the first row of the result set. */ public boolean isFirst() throws DatabaseException { if (getPreviousObject() != null) { return false; } try { if (getObjectCollection().size() > 0) { return getPosition() == 1; } return getResultSet().isFirst(); } catch (SQLException exception) { DatabaseException commException = getAccessor().processExceptionForCommError(getSession(), exception, null); if (commException != null) throw commException; throw DatabaseException.sqlException(exception, getAccessor(), getSession(), false); } }
/** * PUBLIC: * Moves the cursor to the end of the result set, just after the last row. */ public void afterLast() throws DatabaseException { clearNextAndPrevious(); try { getResultSet().afterLast(); setPosition(size() + 1); } catch (SQLException exception) { DatabaseException commException = getAccessor().processExceptionForCommError(getSession(), exception, null); if (commException != null) throw commException; throw DatabaseException.sqlException(exception, getAccessor(), getSession(), false); } }