getSkipBlocks() {
assertInSkipMode();
return skipBlocks;
}
/**
* Gets the index to the current skip block.
*
* @return the current index, 0 if first
*/
public int getSkipBlockIndex() {
assertInSkipMode();
return skipBlockIndex;
}
/**
* Skips to the next logical entity.
* @see #startSkip()
* @throws PersistenceException if not in skipmode
*/
public void skip() {
assertInSkipMode();
if (cursorMovedInSkipMode) {
// re-use old skip blocks
skipBlockIndex++;
if (skipBlockIndex >= skipBlocks.size()) {
throw new PersistenceException(db, "only " + skipBlocks.size() + " skip blocks used so far in " + this);
}
skipBlock = skipBlocks.get(skipBlockIndex);
}
else {
int skippedColumns = skipBlock == null ? 0 : skipBlock.getMaxColumnIndex();
skipBlock = new ResultSetSkipBlock(this, skippedColumns);
skipBlocks.add(skipBlock);
}
}
/**
* Performs a {@link #skipColumns} followed by a {@link #skip} in one method call.
* Provided to save typing only.
*
* @param columnCount the columns to skip
*/
public void skip(int columnCount) {
skipColumns(columnCount);
skip();
}
/**
* Configures a section within this resultset for retrieval.
*
* A section is a logical group of columns within the result set.
* There must be at least one section activated in order to retrieve columns
* by section configuration instead of the traditional way by position or by name.
* A section may span the whole result set or there may be more than one section,
* for example one for each joined table. It's up to the application.
* If {@code configureSection} returns true, a new section was created and
* the columns of this section must be configured once via {@link #configureColumn} in
* the order of their retrieval.
* Otherwise the section is already configured.
* This is the preferred way to retrieve values from a result set, since
* it is the best compromise between speed and flexibility with respect to
* the order of the returned columns.
*
* Example:
*
* if (rs.activateSection(CLASSVARIABLES)) {
* rs.configureColumn(CN_OBJECTCLASS);
* rs.configureColumn(CN_OBJECTID);
* ...
* }
* objectClass = rs.getString();
* objectId = rs.getLong();
* contextObjectId = rs.getLong();
* ...
*
*
* @param key the unique section key, usually the classvariables
* @return true if columns of new section must be configured
* @see #configureColumn(java.lang.String)
*/
public boolean configureSection(Object key) {
if (sections == null) {
sections = new HashMap<>();
}
currentSection = sections.get(key);
if (currentSection == null) {
currentSection = new ResultSetSection(this, key);
sections.put(key, currentSection);
return true;
}
currentSection.resetColumnIndex();
return false;
}
/**
* Configures a column of the current section for automatic retrieval.
*
* @param name the column name
*/
public void configureColumn(String name) {
assertValidSection();
currentSection.configureColumn(name);
}
/**
* Gives the JDBC driver a hint as to the number of rows that should
* be fetched from the database when more rows are needed for this
* ResultSet
object.
* If the fetch size specified is zero, the JDBC driver
* ignores the value and is free to make its own best guess as to what
* the fetch size should be. The default value is set by the
* Statement
object
* that created the result set. The fetch size may be changed at any time.
*
* @param rows the number of rows to fetch
* @see #getFetchSize
*/
public void setFetchSize(int rows) {
try {
rs.setFetchSize(rows);
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Retrieves the fetch size for this
* ResultSet
object.
*
* @return the current fetch size for this ResultSet
object
* @see #setFetchSize
*/
public int getFetchSize() {
try {
return rs.getFetchSize();
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Gives a hint as to the direction in which the rows in this
* ResultSet
object will be processed.
* The initial value is determined by the
* Statement
object
* that produced this ResultSet
object.
* The fetch direction may be changed at any time.
*
* @param direction an int
specifying the suggested
* fetch direction; one of ResultSet.FETCH_FORWARD
,
* ResultSet.FETCH_REVERSE
, or
* ResultSet.FETCH_UNKNOWN
* @see StatementWrapper#setFetchDirection
* @see #getFetchDirection
*/
public void setFetchDirection(int direction) {
try {
rs.setFetchDirection(direction);
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Retrieves the fetch direction for this
* ResultSet
object.
*
* @return the current fetch direction for this ResultSet
object
* @see #setFetchDirection
*/
public int getFetchDirection() {
try {
return rs.getFetchDirection();
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Moves the cursor froward one row from its current position.
* A ResultSet
cursor is initially positioned
* before the first row; the first call to the method
* next
makes the first row the current row; the
* second call makes the second row the current row, and so on.
*
* When a call to the next
method returns false
,
* the cursor is positioned after the last row. Any
* invocation of a ResultSet
method which requires a
* current row will result in a SQLException
being thrown.
* If the result set type is TYPE_FORWARD_ONLY
, it is vendor specified
* whether their JDBC driver implementation will return false
or
* throw an SQLException
on a
* subsequent call to next
.
*
*
If an input stream is open for the current row, a call
* to the method next
will
* implicitly close it. A ResultSet
object's
* warning chain is cleared when a new row is read.
*
* @return true
if the new current row is valid;
* false
if there are no more rows
*/
public boolean next() {
try {
clearSection();
return rs.next();
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Moves the cursor to the previous row in this
* ResultSet
object.
*
* When a call to the previous
method returns false
,
* the cursor is positioned before the first row. Any invocation of a
* ResultSet
method which requires a current row will result in a
* SQLException
being thrown.
*
* If an input stream is open for the current row, a call to the method
* previous
will implicitly close it. A ResultSet
* object's warning change is cleared when a new row is read.
*
* @return true
if the cursor is now positioned on a valid row;
* false
if the cursor is positioned before the first row
*/
public boolean previous () {
try {
clearSection();
return rs.previous();
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Moves the cursor to the first row in
* this ResultSet
object.
*
* @return true
if the cursor is on a valid row;
* false
if there are no rows in the result set
*/
public boolean first () {
try {
clearSection();
return rs.first();
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Moves the cursor to the last row in
* this ResultSet
object.
*
* @return true
if the cursor is on a valid row;
* false
if there are no rows in the result set
*/
public boolean last () {
try {
clearSection();
return rs.last();
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Moves the cursor to the front of
* this ResultSet
object, just before the
* first row. This method has no effect if the result set contains no rows.
*/
public void beforeFirst() {
try {
clearSection();
rs.beforeFirst();
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Moves the cursor to the end of
* this ResultSet
object, just after the
* last row. This method has no effect if the result set contains no rows.
*/
public void afterLast() {
try {
clearSection();
rs.afterLast();
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Retrieves whether the cursor is before the first row in
* this ResultSet
object.
*
* Note:Support for the isBeforeFirst
method
* is optional for ResultSet
s with a result
* set type of TYPE_FORWARD_ONLY
*
* @return true
if the cursor is before the first row;
* false
if the cursor is at any other position or the
* result set contains no rows
*/
public boolean isBeforeFirst() {
try {
return rs.isBeforeFirst();
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Retrieves whether the cursor is after the last row in
* this ResultSet
object.
*
* Note:Support for the isAfterLast
method
* is optional for ResultSet
s with a result
* set type of TYPE_FORWARD_ONLY
*
* @return true
if the cursor is after the last row;
* false
if the cursor is at any other position or the
* result set contains no rows
*/
public boolean isAfterLast() {
try {
return rs.isAfterLast();
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Retrieves the current row number.
* The first row is number 1, the second number 2, and so on.
*
* Note:Support for the getRow
method
* is optional for ResultSet
s with a result
* set type of TYPE_FORWARD_ONLY
*
* @return the current row number; 0
if there is no current row
*/
public int getRow () {
try {
return rs.getRow();
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Moves the cursor to the given row number in
* this ResultSet
object.
*
*
If the row number is positive, the cursor moves to
* the given row number with respect to the
* beginning of the result set. The first row is row 1, the second
* is row 2, and so on.
*
*
If the given row number is negative, the cursor moves to
* an absolute row position with respect to
* the end of the result set. For example, calling the method
* absolute(-1)
positions the
* cursor on the last row; calling the method absolute(-2)
* moves the cursor to the next-to-last row, and so on.
*
*
An attempt to position the cursor beyond the first/last row in
* the result set leaves the cursor before the first row or after
* the last row.
*
*
Note: Calling absolute(1)
is the same
* as calling first()
. Calling absolute(-1)
* is the same as calling last()
.
*
* @param row the number of the row to which the cursor should move.
* A positive number indicates the row number counting from the
* beginning of the result set; a negative number indicates the
* row number counting from the end of the result set
* @return true
if the cursor is moved to a position in this
* ResultSet
object;
* false
if the cursor is before the first row or after the
* last row
*/
public boolean absolute (int row) {
try {
clearSection();
return rs.absolute(row);
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Moves the cursor a relative number of rows, either positive or negative.
* Attempting to move beyond the first/last row in the
* result set positions the cursor before/after the
* the first/last row. Calling relative(0)
is valid, but does
* not change the cursor position.
*
*
Note: Calling the method relative(1)
* is identical to calling the method next()
and
* calling the method relative(-1)
is identical
* to calling the method previous()
.
*
* @param rows an int
specifying the number of rows to
* move from the current row; a positive number moves the cursor
* forward; a negative number moves the cursor backward
* @return true
if the cursor is on a row;
* false
otherwise
*/
public boolean relative (int rows) {
try {
clearSection();
return rs.relative(rows);
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Reports whether
* the last column read had a value of SQL NULL
.
* Note that you must first call one of the getter methods
* on a column to try to read its value and then call
* the method wasNull
to see if the value read was
* SQL NULL
.
*
* @return true
if the last column value read was SQL
* NULL
and false
otherwise
*/
public boolean wasNull() {
try {
return rs.wasNull();
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
// ---------------------- get values by column label ---------------------------
/**
* Retrieves the value of the designated column in the current row.
*
* @param name the label for the column specified with the SQL AS clause.
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Object getObject (String name) {
try {
return rs.getObject(name);
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a String
in the Java programming language.
*
* @param name the label for the column specified with the SQL AS clause. If the SQL AS clause was not specified, then the label is the name of the column
* @param mapNull if empty strings should be treated as null values
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public String getString (String name, boolean mapNull) {
try {
String str = rs.getString (name);
if (mapNull && str != null && str.equals(db.getBackend().getEmptyString())) {
return null;
}
return str;
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a String
in the Java programming language.
*
* @param name the label for the column specified with the SQL AS clause. If the SQL AS clause was not specified, then the label is the name of the column
* @return the column value; if the value is SQL NULL
, the
* value returned is null
* @see #getString(java.lang.String, boolean)
*/
public String getString (String name) {
return getString(name, false);
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a boolean
in the Java programming language.
*
*
If the designated column has a datatype of CHAR or VARCHAR
* and contains a "0" or has a datatype of BIT, TINYINT, SMALLINT, INTEGER or BIGINT
* and contains a 0, a value of false
is returned. If the designated column has a datatype
* of CHAR or VARCHAR
* and contains a "1" or has a datatype of BIT, TINYINT, SMALLINT, INTEGER or BIGINT
* and contains a 1, a value of true
is returned.
*
* @param name the label for the column specified with the SQL AS clause. If the SQL AS clause was not specified, then the label is the name of the column
* @return the column value; if the value is SQL NULL
, the
* value returned is false
*/
public boolean getBoolean (String name) {
try {
return rs.getBoolean(name);
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a Boolean
in the Java programming language.
*
*
If the designated column has a datatype of CHAR or VARCHAR
* and contains a "0" or has a datatype of BIT, TINYINT, SMALLINT, INTEGER or BIGINT
* and contains a 0, a value of false
is returned. If the designated column has a datatype
* of CHAR or VARCHAR
* and contains a "1" or has a datatype of BIT, TINYINT, SMALLINT, INTEGER or BIGINT
* and contains a 1, a value of true
is returned.
*
* @param name the label for the column specified with the SQL AS clause. If the SQL AS clause was not specified, then the label is the name of the column
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Boolean getABoolean (String name) {
boolean value = getBoolean(name);
return wasNull() ? null : value;
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a float
in the Java programming language.
*
* @param name the label for the column specified with the SQL AS clause. If the SQL AS clause was not specified, then the label is the name of the column
* @return the column value; if the value is SQL NULL
, the
* value returned is 0
*/
public float getFloat (String name) {
try {
return rs.getFloat(name);
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a Float
in the Java programming language.
*
* @param name the label for the column specified with the SQL AS clause. If the SQL AS clause was not specified, then the label is the name of the column
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Float getAFloat (String name) {
float value = getFloat(name);
return wasNull() ? null : value;
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a double
in the Java programming language.
*
* @param name the label for the column specified with the SQL AS clause. If the SQL AS clause was not specified, then the label is the name of the column
* @return the column value; if the value is SQL NULL
, the
* value returned is 0
*/
public double getDouble (String name) {
try {
return rs.getDouble(name);
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a Double
in the Java programming language.
*
* @param name the label for the column specified with the SQL AS clause. If the SQL AS clause was not specified, then the label is the name of the column
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Double getADouble (String name) {
double value = getDouble(name);
return wasNull() ? null : value;
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as a
* java.math.BigDecimal
with full precision.
*
* @param name the label for the column specified with the SQL AS clause. If the SQL AS clause was not specified, then the label is the name of the column
* @return the column value (full precision);
* if the value is SQL NULL
, the value returned is
* null
in the Java programming language.
*/
public BigDecimal getBigDecimal (String name) {
try {
return rs.getBigDecimal(name);
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as a
* BMoney
with full precision.
* Notice that BMoney fields use two fields:
* one for the value and
* one for the scale (= name + "_2")
*
* @param name the label for the column specified with the SQL AS clause. If the SQL AS clause was not specified, then the label is the name of the column
* @return the column value (full precision);
* if the value is SQL NULL
, the value returned is
* null
in the Java programming language.
*/
public BMoney getBMoney (String name) {
double value = getDouble(name);
return wasNull() ? null : new BMoney (value, getInt(name + "_2"));
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as a
* DMoney
with full precision.
* Notice that DMoney fields use two fields:
* one for the value and
* one for the scale (= name + "_2")
*
* @param name the label for the column specified with the SQL AS clause. If the SQL AS clause was not specified, then the label is the name of the column
* @return the column value (full precision);
* if the value is SQL NULL
, the value returned is
* null
in the Java programming language.
*/
public DMoney getDMoney (String name) {
try {
BigDecimal decimal = rs.getBigDecimal(name);
if (!wasNull()) {
// set scale
return new DMoney(decimal.movePointLeft(getInt(name + "_2")));
}
else {
return null;
}
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a byte
in the Java programming language.
*
* @param name the label for the column specified with the SQL AS clause. If the SQL AS clause was not specified, then the label is the name of the column
* @return the column value; if the value is SQL NULL
, the
* value returned is 0
*/
public byte getByte (String name) {
try {
return rs.getByte(name);
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a Byte
in the Java programming language.
*
* @param name the label for the column specified with the SQL AS clause. If the SQL AS clause was not specified, then the label is the name of the column
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Byte getAByte (String name) {
byte value = getByte(name);
return wasNull() ? null : value;
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a char
in the Java programming language.
*
* @param name the label for the column specified with the SQL AS clause. If the SQL AS clause was not specified, then the label is the name of the column
* @return the column value; if the value is SQL NULL
or the empty string, the
* value returned is 0
*/
public char getChar (String name) {
try {
String val = rs.getString(name);
return val == null || val.length() == 0 ? 0 : val.charAt(0);
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a Character
in the Java programming language.
*
* @param name the label for the column specified with the SQL AS clause.
* If the SQL AS clause was not specified, then the label is the name of the column.
* @param mapNull if blanks should be treated as null values
* @return the column value; if the value is SQL NULL
, the
* value returned is null
. If the value is the empty string the returned
* value is new Character(0)
.
*/
public Character getCharacter (String name, boolean mapNull) {
char value = getChar(name);
return wasNull() ? null : (mapNull && value == ' ' ? null : value);
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a Character
in the Java programming language.
*
* @param name the label for the column specified with the SQL AS clause.
* If the SQL AS clause was not specified, then the label is the name of the column.
* @return the column value; if the value is SQL NULL
, the
* value returned is null
. If the value is the empty string the returned
* value is new Character(0)
.
*/
public Character getCharacter (String name) {
return getCharacter(name, false);
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a short
in the Java programming language.
*
* @param name the label for the column specified with the SQL AS clause. If the SQL AS clause was not specified, then the label is the name of the column
* @return the column value; if the value is SQL NULL
, the
* value returned is 0
*/
public short getShort (String name) {
try {
return rs.getShort(name);
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a Short
in the Java programming language.
*
* @param name the label for the column specified with the SQL AS clause. If the SQL AS clause was not specified, then the label is the name of the column
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Short getAShort (String name) {
short value = getShort(name);
return wasNull() ? null : value;
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* an int
in the Java programming language.
*
* @param name the label for the column specified with the SQL AS clause. If the SQL AS clause was not specified, then the label is the name of the column
* @return the column value; if the value is SQL NULL
, the
* value returned is 0
*/
public int getInt (String name) {
try {
return rs.getInt(name);
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* an Integer
in the Java programming language.
*
* @param name the label for the column specified with the SQL AS clause. If the SQL AS clause was not specified, then the label is the name of the column
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Integer getInteger (String name) {
int value = getInt(name);
return wasNull() ? null : value;
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a long
in the Java programming language.
*
* @param name the label for the column specified with the SQL AS clause. If the SQL AS clause was not specified, then the label is the name of the column
* @return the column value; if the value is SQL NULL
, the
* value returned is 0
*/
public long getLong (String name) {
try {
return rs.getLong(name);
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a Long
in the Java programming language.
*
* @param name the label for the column specified with the SQL AS clause. If the SQL AS clause was not specified, then the label is the name of the column
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Long getALong (String name) {
long value = getLong(name);
return wasNull() ? null : value;
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.sql.Date
in the Java programming language.
*
* @param name the label for the column specified with the SQL AS clause.
* If the SQL AS clause was not specified, then the label is the name of the column
* @param timezone the calendar providing the timezone configuration
* @param mapNull true if 1.1.1970 should be mapped to null
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Date getDate(String name, Calendar timezone, boolean mapNull) {
try {
java.sql.Date date = timezone == null ?
rs.getDate(name) : rs.getDate(name, timezone);
if (date == null ||
(mapNull && date.equals(DateHelper.MIN_DATE))) {
// mindate is translated back to null
return null;
}
return Date.createFrozen(date.getTime());
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.time.LocalDate
in the Java programming language.
*
* @param name the label for the column specified with the SQL AS clause.
* If the SQL AS clause was not specified, then the label is the name of the column
* @param timezone the calendar providing the timezone configuration
* @param mapNull true if 1.1.1970 should be mapped to null
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public LocalDate getLocalDate(String name, Calendar timezone, boolean mapNull) {
Date date = getDate(name, timezone, mapNull);
return date == null ? null : date.toLocalDate();
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.sql.Date
in the Java programming language.
*
* @param name the label for the column specified with the SQL AS clause.
* If the SQL AS clause was not specified, then the label is the name of the column
* @param timezone the calendar providing the timezone configuration
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Date getDate(String name, Calendar timezone) {
return getDate(name, timezone, false);
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.time.LocalDate
in the Java programming language.
*
* @param name the label for the column specified with the SQL AS clause.
* If the SQL AS clause was not specified, then the label is the name of the column
* @param timezone the calendar providing the timezone configuration
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public LocalDate getLocalDate(String name, Calendar timezone) {
return getLocalDate(name, timezone, false);
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.sql.Date
in the Java programming language.
*
* @param name the label for the column specified with the SQL AS clause.
* If the SQL AS clause was not specified, then the label is the name of the column
* @param mapNull true if 1.1.1970 should be mapped to null
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Date getDate(String name, boolean mapNull) {
return getDate(name, null, mapNull);
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.time.LocalDate
in the Java programming language.
*
* @param name the label for the column specified with the SQL AS clause.
* If the SQL AS clause was not specified, then the label is the name of the column
* @param mapNull true if 1.1.1970 should be mapped to null
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public LocalDate getLocalDate(String name, boolean mapNull) {
return getLocalDate(name, null, mapNull);
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.sql.Date
in the Java programming language.
*
* @param name the label for the column specified with the SQL AS clause.
* If the SQL AS clause was not specified, then the label is the name of the column
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Date getDate(String name) {
return getDate(name, null, false);
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.time.LocalDate
in the Java programming language.
*
* @param name the label for the column specified with the SQL AS clause.
* If the SQL AS clause was not specified, then the label is the name of the column
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public LocalDate getLocalDate(String name) {
return getLocalDate(name, null, false);
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.sql.Timestamp
in the Java programming language.
*
* @param name the label for the column specified with the SQL AS clause.
* If the SQL AS clause was not specified, then the label is the name of the column
* @param timezone the calendar providing the timezone configuration
* @param mapNull true if 1.1.1970 00:00:00.000 should be mapped to null
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Timestamp getTimestamp(String name, Calendar timezone, boolean mapNull) {
try {
java.sql.Timestamp ts = timezone == null ?
rs.getTimestamp(name) : rs.getTimestamp(name, timezone);
if (ts == null ||
(mapNull && ts.equals(DateHelper.MIN_TIMESTAMP))) {
// mintimestamp is translated back to null
return null;
}
return Timestamp.createFrozen(ts.getTime(), ts.getNanos());
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.time.LocalDateTime
in the Java programming language.
*
* @param name the label for the column specified with the SQL AS clause.
* If the SQL AS clause was not specified, then the label is the name of the column
* @param timezone the calendar providing the timezone configuration
* @param mapNull true if 1.1.1970 00:00:00.000 should be mapped to null
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public LocalDateTime getLocalDateTime(String name, Calendar timezone, boolean mapNull) {
Timestamp ts = getTimestamp(name, timezone, mapNull);
return ts == null ? null : ts.toLocalDateTime();
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.sql.Timestamp
in the Java programming language.
*
* @param name the label for the column specified with the SQL AS clause.
* If the SQL AS clause was not specified, then the label is the name of the column
* @param timezone the calendar providing the timezone configuration
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Timestamp getTimestamp(String name, Calendar timezone) {
return getTimestamp(name, timezone, false);
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.time.LocalDateTime
in the Java programming language.
*
* @param name the label for the column specified with the SQL AS clause.
* If the SQL AS clause was not specified, then the label is the name of the column
* @param timezone the calendar providing the timezone configuration
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public LocalDateTime getLocalDateTime(String name, Calendar timezone) {
return getLocalDateTime(name, timezone, false);
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.sql.Timestamp
in the Java programming language.
*
* @param name the label for the column specified with the SQL AS clause.
* If the SQL AS clause was not specified, then the label is the name of the column
* @param mapNull true if 1.1.1970 00:00:00.000 should be mapped to null
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Timestamp getTimestamp(String name, boolean mapNull) {
return getTimestamp(name, null, mapNull);
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.time.LocalDateTime
in the Java programming language.
*
* @param name the label for the column specified with the SQL AS clause.
* If the SQL AS clause was not specified, then the label is the name of the column
* @param mapNull true if 1.1.1970 00:00:00.000 should be mapped to null
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public LocalDateTime getLocalDateTime(String name, boolean mapNull) {
return getLocalDateTime(name, null, mapNull);
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.sql.Timestamp
in the Java programming language.
*
* @param name the label for the column specified with the SQL AS clause.
* If the SQL AS clause was not specified, then the label is the name of the column
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Timestamp getTimestamp(String name) {
return getTimestamp(name, null, false);
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.time.LocalDateTime
in the Java programming language.
*
* @param name the label for the column specified with the SQL AS clause.
* If the SQL AS clause was not specified, then the label is the name of the column
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public LocalDateTime getLocalDateTime(String name) {
return getLocalDateTime(name, null, false);
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.sql.Time
in the Java programming language.
*
* @param name the label for the column specified with the SQL AS clause.
* If the SQL AS clause was not specified, then the label is the name of the column
* @param timezone the calendar providing the timezone configuration
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Time getTime(String name, Calendar timezone) {
try {
// no minTime (makes no sense, see PreparedStatementWrapper)
java.sql.Time time = timezone == null ?
rs.getTime(name) : rs.getTime(name, timezone);
return time == null ? null : Time.createFrozen(time.getTime());
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.time.LocalTime
in the Java programming language.
*
* @param name the label for the column specified with the SQL AS clause.
* If the SQL AS clause was not specified, then the label is the name of the column
* @param timezone the calendar providing the timezone configuration
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public LocalTime getLocalTime(String name, Calendar timezone) {
Time time = getTime(name, timezone);
return time == null ? null : time.toLocalTime();
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.sql.Time
in the Java programming language.
*
* @param name the label for the column specified with the SQL AS clause.
* If the SQL AS clause was not specified, then the label is the name of the column
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Time getTime(String name) {
return getTime(name, null);
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.time.LocalTime
in the Java programming language.
*
* @param name the label for the column specified with the SQL AS clause.
* If the SQL AS clause was not specified, then the label is the name of the column
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public LocalTime getLocalTime(String name) {
return getLocalTime(name, null);
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a {@link Binary} in the Java programming language.
*
* @param name the label for the column specified with the SQL AS clause.
* If the SQL AS clause was not specified, then the label is the name of the column
* @param bufSize the initial buffersize for the Binary
* @return the binary read from db
*/
public Binary getBinary(String name, int bufSize) {
try {
return Binary.createBinary(rs.getBinaryStream(name), bufSize, true);
}
catch (SQLException | IOException e) {
throw new PersistenceException(db, e);
}
}
// ------------------- getter with positions -----------------------------
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a String
in the Java programming language.
*
* @param pos the parameter index in the result set
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Object getObject (int pos) {
try {
return rs.getObject (pos + columnOffset);
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a String
in the Java programming language.
*
* @param pos the parameter index in the result set
* @param mapNull if empty strings should be treated as null values
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public String getString (int pos, boolean mapNull) {
try {
String str = rs.getString (pos + columnOffset);
if (mapNull && str != null && str.equals(db.getBackend().getEmptyString())) {
return null;
}
return str;
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a String
in the Java programming language.
*
* @param pos the parameter index in the result set
* @return the column value; if the value is SQL NULL
, the
* value returned is null
* @see #getString(java.lang.String, boolean)
*/
public String getString (int pos) {
return getString(pos, false);
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a boolean
in the Java programming language.
*
* If the designated column has a datatype of CHAR or VARCHAR
* and contains a "0" or has a datatype of BIT, TINYINT, SMALLINT, INTEGER or BIGINT
* and contains a 0, a value of false
is returned. If the designated column has a datatype
* of CHAR or VARCHAR
* and contains a "1" or has a datatype of BIT, TINYINT, SMALLINT, INTEGER or BIGINT
* and contains a 1, a value of true
is returned.
*
* @param pos the parameter index in the result set
* @return the column value; if the value is SQL NULL
, the
* value returned is false
*/
public boolean getBoolean (int pos) {
try {
return rs.getBoolean(pos + columnOffset);
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a Boolean
in the Java programming language.
*
*
If the designated column has a datatype of CHAR or VARCHAR
* and contains a "0" or has a datatype of BIT, TINYINT, SMALLINT, INTEGER or BIGINT
* and contains a 0, a value of false
is returned. If the designated column has a datatype
* of CHAR or VARCHAR
* and contains a "1" or has a datatype of BIT, TINYINT, SMALLINT, INTEGER or BIGINT
* and contains a 1, a value of true
is returned.
*
* @param pos the parameter index in the result set
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Boolean getABoolean (int pos) {
boolean value = getBoolean(pos);
return wasNull() ? null : value;
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a float
in the Java programming language.
*
* @param pos the parameter index in the result set
* @return the column value; if the value is SQL NULL
, the
* value returned is 0
*/
public float getFloat (int pos) {
try {
return rs.getFloat(pos + columnOffset);
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a Float
in the Java programming language.
*
* @param pos the parameter index in the result set
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Float getAFloat (int pos) {
float value = getFloat(pos);
return wasNull() ? null : value;
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a double
in the Java programming language.
*
* @param pos the parameter index in the result set
* @return the column value; if the value is SQL NULL
, the
* value returned is 0
*/
public double getDouble (int pos) {
try {
return rs.getDouble(pos + columnOffset);
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a Double
in the Java programming language.
*
* @param pos the parameter index in the result set
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Double getADouble (int pos) {
double value = getDouble(pos);
return wasNull() ? null : value;
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as a
* java.math.BigDecimal
with full precision.
*
* @param pos the parameter index in the result set
* @return the column value (full precision);
* if the value is SQL NULL
, the value returned is
* null
in the Java programming language.
*/
public BigDecimal getBigDecimal (int pos) {
try {
return rs.getBigDecimal(pos + columnOffset);
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as a
* BMoney
with full precision.
* Notice that BMoney fields use two fields:
* one for the value and
* one for the scale (= name + "P")
*
* @param pos the parameter index for the amount in the result set
* @param ppos the parameter index for the scale in the result set
* @return the column value (full precision);
* if the value is SQL NULL
, the value returned is
* null
in the Java programming language.
*/
public BMoney getBMoney (int pos, int ppos) {
double value = getDouble(pos);
return wasNull() ? null : new BMoney (value, getInt(ppos));
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as a
* DMoney
with full precision.
* Notice that DMoney fields use two fields:
* one for the value and
* one for the scale (= name + "P")
*
* @param pos the parameter index for the amount in the result set
* @param ppos the parameter index for the scale in the result set
* @return the column value (full precision);
* if the value is SQL NULL
, the value returned is
* null
in the Java programming language.
*/
public DMoney getDMoney (int pos, int ppos) {
BigDecimal value = getBigDecimal(pos);
return wasNull() ? null : new DMoney (value.movePointLeft(getInt(ppos)));
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a byte
in the Java programming language.
*
* @param pos the parameter index in the result set
* @return the column value; if the value is SQL NULL
, the
* value returned is 0
*/
public byte getByte (int pos) {
try {
return rs.getByte(pos + columnOffset);
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a Byte
in the Java programming language.
*
* @param pos the parameter index in the result set
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Byte getAByte (int pos) {
byte value = getByte(pos);
return wasNull() ? null : value;
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a char
in the Java programming language.
*
* @param pos the parameter index in the result set
* @return the column value; if the value is SQL NULL
or the empty string, the
* value returned is 0
*/
public char getChar (int pos) {
try {
String val = rs.getString(pos + columnOffset);
return val == null || val.length() == 0 ? 0 : val.charAt(0);
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a Character
in the Java programming language.
*
* @param pos the parameter index in the result set
* @param mapNull if blanks should be treated as null values
* @return the column value; if the value is SQL NULL
, the
* value returned is null
. If the value is the empty string the returned
* value is new Character(0)
.
*
*/
public Character getCharacter (int pos, boolean mapNull) {
char value = getChar(pos);
return wasNull() ? null : (mapNull && value == ' ' ? null : value);
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a Character
in the Java programming language.
*
* @param pos the parameter index in the result set
* @return the column value; if the value is SQL NULL
, the
* value returned is null
. If the value is the empty string the returned
* value is new Character(0)
.
*
*/
public Character getCharacter (int pos) {
return getCharacter(pos, false);
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a short
in the Java programming language.
*
* @param pos the parameter index in the result set
* @return the column value; if the value is SQL NULL
, the
* value returned is 0
*/
public short getShort (int pos) {
try {
return rs.getShort(pos + columnOffset);
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a Short
in the Java programming language.
*
* @param pos the parameter index in the result set
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Short getAShort (int pos) {
short value = getShort(pos);
return wasNull() ? null : value;
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* an int
in the Java programming language.
*
* @param pos the parameter index in the result set
* @return the column value; if the value is SQL NULL
, the
* value returned is 0
*/
public int getInt (int pos) {
try {
return rs.getInt(pos + columnOffset);
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* an Integer
in the Java programming language.
*
* @param pos the parameter index in the result set
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Integer getInteger (int pos) {
int value = getInt(pos);
return wasNull() ? null : value;
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a long
in the Java programming language.
*
* @param pos the parameter index in the result set
* @return the column value; if the value is SQL NULL
, the
* value returned is 0
*/
public long getLong (int pos) {
try {
return rs.getLong(pos + columnOffset);
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a Long
in the Java programming language.
*
* @param pos the parameter index in the result set
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Long getALong (int pos) {
long value = getLong(pos);
return wasNull() ? null : value;
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.sql.Date
in the Java programming language.
*
* @param pos the parameter index in the result set
* @param timezone the calendar providing the timezone configuration
* @param mapNull true if 1.1.1970 should be mapped to null
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Date getDate(int pos, Calendar timezone, boolean mapNull) {
try {
java.sql.Date date = timezone == null ?
rs.getDate(pos + columnOffset) : rs.getDate(pos + columnOffset, timezone);
if (date == null ||
(mapNull && date.equals(DateHelper.MIN_DATE))) {
// mindate is translated back to null
return null;
}
return Date.createFrozen(date.getTime());
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.time.LocalDate
in the Java programming language.
*
* @param pos the parameter index in the result set
* @param timezone the calendar providing the timezone configuration
* @param mapNull true if 1.1.1970 should be mapped to null
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public LocalDate getLocalDate(int pos, Calendar timezone, boolean mapNull) {
Date date = getDate(pos, timezone, mapNull);
return date == null ? null : date.toLocalDate();
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.sql.Date
in the Java programming language.
*
* @param pos the parameter index in the result set
* @param mapNull true if 1.1.1970 should be mapped to null
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Date getDate(int pos, boolean mapNull) {
return getDate(pos, null, mapNull);
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.time.LocalDate
in the Java programming language.
*
* @param pos the parameter index in the result set
* @param mapNull true if 1.1.1970 should be mapped to null
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public LocalDate getLocalDate(int pos, boolean mapNull) {
return getLocalDate(pos, null, mapNull);
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.sql.Date
in the Java programming language.
*
* @param pos the parameter index in the result set
* @param timezone the calendar providing the timezone configuration
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Date getDate(int pos, Calendar timezone) {
return getDate(pos, timezone, false);
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.time.LocalDate
in the Java programming language.
*
* @param pos the parameter index in the result set
* @param timezone the calendar providing the timezone configuration
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public LocalDate getLocalDate(int pos, Calendar timezone) {
return getLocalDate(pos, timezone, false);
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.sql.Date
in the Java programming language.
*
* @param pos the parameter index in the result set
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Date getDate(int pos) {
return getDate(pos, null, false);
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.time.LocalDate
in the Java programming language.
*
* @param pos the parameter index in the result set
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public LocalDate getLocalDate(int pos) {
return getLocalDate(pos, null, false);
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.sql.Timestamp
in the Java programming language.
*
* @param pos the parameter index in the result set
* @param timezone the calendar providing the timezone configuration
* @param mapNull true if 1.1.1970 00:00:00.000 should be mapped to null
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Timestamp getTimestamp(int pos, Calendar timezone, boolean mapNull) {
try {
java.sql.Timestamp ts = timezone == null ?
rs.getTimestamp(pos + columnOffset) : rs.getTimestamp(pos + columnOffset, timezone);
if (ts == null ||
(mapNull && ts.equals(DateHelper.MIN_TIMESTAMP))) {
// mindate is translated back to null
return null;
}
return Timestamp.createFrozen(ts.getTime(), ts.getNanos());
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.time.LocalDateTime
in the Java programming language.
*
* @param pos the parameter index in the result set
* @param timezone the calendar providing the timezone configuration
* @param mapNull true if 1.1.1970 00:00:00.000 should be mapped to null
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public LocalDateTime getLocalDateTime(int pos, Calendar timezone, boolean mapNull) {
Timestamp ts = getTimestamp(pos, timezone, mapNull);
return ts == null ? null : ts.toLocalDateTime();
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.sql.Timestamp
in the Java programming language.
*
* @param pos the parameter index in the result set
* @param mapNull true if 1.1.1970 00:00:00.000 should be mapped to null
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Timestamp getTimestamp(int pos, boolean mapNull) {
return getTimestamp(pos, null, mapNull);
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.time.LocalDateTime
in the Java programming language.
*
* @param pos the parameter index in the result set
* @param mapNull true if 1.1.1970 00:00:00.000 should be mapped to null
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public LocalDateTime getLocalDateTime(int pos, boolean mapNull) {
return getLocalDateTime(pos, null, mapNull);
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.sql.Timestamp
in the Java programming language.
*
* @param pos the parameter index in the result set
* @param timezone the calendar providing the timezone configuration
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Timestamp getTimestamp(int pos, Calendar timezone) {
return getTimestamp(pos, timezone, false);
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.time.LocalDateTime
in the Java programming language.
*
* @param pos the parameter index in the result set
* @param timezone the calendar providing the timezone configuration
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public LocalDateTime getLocalDateTime(int pos, Calendar timezone) {
return getLocalDateTime(pos, timezone, false);
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.sql.Timestamp
in the Java programming language.
*
* @param pos the parameter index in the result set
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Timestamp getTimestamp(int pos) {
return getTimestamp(pos, null, false);
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.time.LocalDateTime
in the Java programming language.
*
* @param pos the parameter index in the result set
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public LocalDateTime getLocalDateTime(int pos) {
return getLocalDateTime(pos, null, false);
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.sql.Time
in the Java programming language.
*
* @param pos the parameter index in the result set
* @param timezone the calendar providing the timezone configuration
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Time getTime(int pos, Calendar timezone) {
try {
// no mapNull possible
java.sql.Time time = timezone == null ?
rs.getTime(pos + columnOffset) : rs.getTime(pos + columnOffset, timezone);
return time == null ? null : Time.createFrozen(time.getTime());
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.time.LocalTime
in the Java programming language.
*
* @param pos the parameter index in the result set
* @param timezone the calendar providing the timezone configuration
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public LocalTime getLocalTime(int pos, Calendar timezone) {
Time time = getTime(pos, timezone);
return time == null ? null : time.toLocalTime();
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.sql.Time
in the Java programming language.
*
* @param pos the parameter index in the result set
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Time getTime(int pos) {
return getTime(pos, null);
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.time.LocalTime
in the Java programming language.
*
* @param pos the parameter index in the result set
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public LocalTime getLocalTime(int pos) {
return getLocalTime(pos, null);
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a {@link Binary} in the Java programming language.
*
* @param pos the parameter index in the result set
* @param bufSize the initial buffersize for the Binary
* @return the binary read from db
*/
public Binary getBinary(int pos, int bufSize) {
try {
return Binary.createBinary(rs.getBinaryStream(pos + columnOffset), bufSize, true);
}
catch (SQLException | IOException e) {
throw new PersistenceException(db, e);
}
}
// ------------------- getter with automatic column index -----------------------------
/**
* Retrieves the value of the configured column in the current row
* of this ResultSet
object as
* a String
in the Java programming language.
*
* @param mapNull if empty strings should be treated as null values
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public String getString (boolean mapNull) {
try {
String str = rs.getString (nextConfiguredIndex() + columnOffset);
if (mapNull && str != null && str.equals(db.getBackend().getEmptyString())) {
return null;
}
return str;
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Retrieves the value of the configured column in the current row
* of this ResultSet
object as
* a String
in the Java programming language.
*
* @return the column value; if the value is SQL NULL
, the
* value returned is null
* @see #getString(java.lang.String, boolean)
*/
public String getString () {
return getString(nextConfiguredIndex(), false);
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a boolean
in the Java programming language.
*
* If the designated column has a datatype of CHAR or VARCHAR
* and contains a "0" or has a datatype of BIT, TINYINT, SMALLINT, INTEGER or BIGINT
* and contains a 0, a value of false
is returned. If the designated column has a datatype
* of CHAR or VARCHAR
* and contains a "1" or has a datatype of BIT, TINYINT, SMALLINT, INTEGER or BIGINT
* and contains a 1, a value of true
is returned.
*
* @return the column value; if the value is SQL NULL
, the
* value returned is false
*/
public boolean getBoolean () {
try {
return rs.getBoolean(nextConfiguredIndex() + columnOffset);
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a Boolean
in the Java programming language.
*
*
If the designated column has a datatype of CHAR or VARCHAR
* and contains a "0" or has a datatype of BIT, TINYINT, SMALLINT, INTEGER or BIGINT
* and contains a 0, a value of false
is returned. If the designated column has a datatype
* of CHAR or VARCHAR
* and contains a "1" or has a datatype of BIT, TINYINT, SMALLINT, INTEGER or BIGINT
* and contains a 1, a value of true
is returned.
*
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Boolean getABoolean () {
boolean value = getBoolean(nextConfiguredIndex());
return wasNull() ? null : value;
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a float
in the Java programming language.
*
* @return the column value; if the value is SQL NULL
, the
* value returned is 0
*/
public float getFloat () {
try {
return rs.getFloat(nextConfiguredIndex() + columnOffset);
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a Float
in the Java programming language.
*
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Float getAFloat () {
float value = getFloat(nextConfiguredIndex());
return wasNull() ? null : value;
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a double
in the Java programming language.
*
* @return the column value; if the value is SQL NULL
, the
* value returned is 0
*/
public double getDouble () {
try {
return rs.getDouble(nextConfiguredIndex() + columnOffset);
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a Double
in the Java programming language.
*
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Double getADouble () {
double value = getDouble(nextConfiguredIndex());
return wasNull() ? null : value;
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as a
* java.math.BigDecimal
with full precision.
*
* @return the column value (full precision);
* if the value is SQL NULL
, the value returned is
* null
in the Java programming language.
*/
public BigDecimal getBigDecimal () {
try {
return rs.getBigDecimal(nextConfiguredIndex() + columnOffset);
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as a
* BMoney
with full precision.
* Notice that BMoney fields use two fields:
* one for the value and
* one for the scale (= name + "P")
*
* @return the column value (full precision);
* if the value is SQL NULL
, the value returned is
* null
in the Java programming language.
*/
public BMoney getBMoney () {
double value = getDouble(nextConfiguredIndex());
return wasNull() ? null : new BMoney (value, getInt(nextConfiguredIndex()));
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as a
* DMoney
with full precision.
* Notice that DMoney fields use two fields:
* one for the value and
* one for the scale (= name + "P")
*
* @return the column value (full precision);
* if the value is SQL NULL
, the value returned is
* null
in the Java programming language.
*/
public DMoney getDMoney () {
BigDecimal value = getBigDecimal(nextConfiguredIndex());
return wasNull() ? null : new DMoney (value.movePointLeft(getInt(nextConfiguredIndex())));
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a byte
in the Java programming language.
*
* @return the column value; if the value is SQL NULL
, the
* value returned is 0
*/
public byte getByte () {
try {
return rs.getByte(nextConfiguredIndex() + columnOffset);
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a Byte
in the Java programming language.
*
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Byte getAByte () {
byte value = getByte(nextConfiguredIndex());
return wasNull() ? null : value;
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a char
in the Java programming language.
*
* @return the column value; if the value is SQL NULL
or the empty string, the
* value returned is 0
*/
public char getChar () {
try {
String val = rs.getString(nextConfiguredIndex() + columnOffset);
return val == null || val.length() == 0 ? 0 : val.charAt(0);
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a Character
in the Java programming language.
*
* @param mapNull if blanks should be treated as null values
* @return the column value; if the value is SQL NULL
, the
* value returned is null
. If the value is the empty string the returned
* value is new Character(0)
.
*
*/
public Character getCharacter (boolean mapNull) {
char value = getChar(nextConfiguredIndex());
return wasNull() ? null : (mapNull && value == ' ' ? null : value);
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a Character
in the Java programming language.
*
* @return the column value; if the value is SQL NULL
, the
* value returned is null
. If the value is the empty string the returned
* value is new Character(0)
.
*
*/
public Character getCharacter () {
return getCharacter(nextConfiguredIndex(), false);
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a short
in the Java programming language.
*
* @return the column value; if the value is SQL NULL
, the
* value returned is 0
*/
public short getShort () {
try {
return rs.getShort(nextConfiguredIndex() + columnOffset);
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a Short
in the Java programming language.
*
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Short getAShort () {
short value = getShort(nextConfiguredIndex());
return wasNull() ? null : value;
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* an int
in the Java programming language.
*
* @return the column value; if the value is SQL NULL
, the
* value returned is 0
*/
public int getInt () {
try {
return rs.getInt(nextConfiguredIndex() + columnOffset);
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* an Integer
in the Java programming language.
*
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Integer getInteger () {
int value = getInt(nextConfiguredIndex());
return wasNull() ? null : value;
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a long
in the Java programming language.
*
* @return the column value; if the value is SQL NULL
, the
* value returned is 0
*/
public long getLong () {
try {
return rs.getLong(nextConfiguredIndex() + columnOffset);
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a Long
in the Java programming language.
*
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Long getALong () {
long value = getLong(nextConfiguredIndex());
return wasNull() ? null : value;
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.sql.Date
in the Java programming language.
*
* @param timezone the calendar providing the timezone configuration
* @param mapNull true if 1.1.1970 should be mapped to null
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Date getDate(Calendar timezone, boolean mapNull) {
try {
int pos = nextConfiguredIndex();
java.sql.Date date = timezone == null ?
rs.getDate(pos + columnOffset) : rs.getDate(pos + columnOffset, timezone);
if (date == null ||
(mapNull && date.equals(DateHelper.MIN_DATE))) {
// mindate is translated back to null
return null;
}
return Date.createFrozen(date.getTime());
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.time.LocalDate
in the Java programming language.
*
* @param timezone the calendar providing the timezone configuration
* @param mapNull true if 1.1.1970 should be mapped to null
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public LocalDate getLocalDate(Calendar timezone, boolean mapNull) {
Date date = getDate(timezone, mapNull);
return date == null ? null : date.toLocalDate();
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.sql.Date
in the Java programming language.
*
* @param mapNull true if 1.1.1970 should be mapped to null
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Date getDate(boolean mapNull) {
return getDate(nextConfiguredIndex(), null, mapNull);
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.time.LocalDate
in the Java programming language.
*
* @param mapNull true if 1.1.1970 should be mapped to null
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public LocalDate getLocalDate(boolean mapNull) {
return getLocalDate(nextConfiguredIndex(), null, mapNull);
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.sql.Date
in the Java programming language.
*
* @param timezone the calendar providing the timezone configuration
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Date getDate(Calendar timezone) {
return getDate(nextConfiguredIndex(), timezone, false);
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.time.LocalDate
in the Java programming language.
*
* @param timezone the calendar providing the timezone configuration
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public LocalDate getLocalDate(Calendar timezone) {
return getLocalDate(nextConfiguredIndex(), timezone, false);
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.sql.Date
in the Java programming language.
*
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Date getDate() {
return getDate(nextConfiguredIndex(), null, false);
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.time.LocalDate
in the Java programming language.
*
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public LocalDate getLocalDate() {
return getLocalDate(nextConfiguredIndex(), null, false);
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.sql.Timestamp
in the Java programming language.
*
* @param timezone the calendar providing the timezone configuration
* @param mapNull true if 1.1.1970 00:00:00.000 should be mapped to null
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Timestamp getTimestamp(Calendar timezone, boolean mapNull) {
try {
int pos = nextConfiguredIndex();
java.sql.Timestamp ts = timezone == null ?
rs.getTimestamp(pos + columnOffset) : rs.getTimestamp(pos + columnOffset, timezone);
if (ts == null ||
(mapNull && ts.equals(DateHelper.MIN_TIMESTAMP))) {
// mindate is translated back to null
return null;
}
return Timestamp.createFrozen(ts.getTime(), ts.getNanos());
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.time.LocalDateTime
in the Java programming language.
*
* @param timezone the calendar providing the timezone configuration
* @param mapNull true if 1.1.1970 00:00:00.000 should be mapped to null
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public LocalDateTime getLocalDateTime(Calendar timezone, boolean mapNull) {
Timestamp ts = getTimestamp(timezone, mapNull);
return ts == null ? null : ts.toLocalDateTime();
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.sql.Timestamp
in the Java programming language.
*
* @param mapNull true if 1.1.1970 00:00:00.000 should be mapped to null
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Timestamp getTimestamp(boolean mapNull) {
return getTimestamp(nextConfiguredIndex(), null, mapNull);
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.time.LocalDateTime
in the Java programming language.
*
* @param mapNull true if 1.1.1970 00:00:00.000 should be mapped to null
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public LocalDateTime getLocalDateTime(boolean mapNull) {
return getLocalDateTime(nextConfiguredIndex(), null, mapNull);
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.sql.Timestamp
in the Java programming language.
*
* @param timezone the calendar providing the timezone configuration
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Timestamp getTimestamp(Calendar timezone) {
return getTimestamp(nextConfiguredIndex(), timezone, false);
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.time.LocalDateTime
in the Java programming language.
*
* @param timezone the calendar providing the timezone configuration
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public LocalDateTime getLocalDateTime(Calendar timezone) {
return getLocalDateTime(nextConfiguredIndex(), timezone, false);
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.sql.Timestamp
in the Java programming language.
*
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Timestamp getTimestamp() {
return getTimestamp(nextConfiguredIndex(), null, false);
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.time.LocalDateTime
in the Java programming language.
*
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public LocalDateTime getLocalDateTime() {
return getLocalDateTime(nextConfiguredIndex(), null, false);
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.sql.Time
in the Java programming language.
*
* @param timezone the calendar providing the timezone configuration
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Time getTime(Calendar timezone) {
try {
// no mapNull possible
int pos = nextConfiguredIndex();
java.sql.Time time = timezone == null ?
rs.getTime(pos + columnOffset) : rs.getTime(pos + columnOffset, timezone);
return time == null ? null : Time.createFrozen(time.getTime());
}
catch (SQLException e) {
throw new PersistenceException(db, e);
}
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.time.LocalTime
in the Java programming language.
*
* @param timezone the calendar providing the timezone configuration
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public LocalTime getLocalTime(Calendar timezone) {
Time time = getTime(timezone);
return time == null ? null : time.toLocalTime();
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.sql.Time
in the Java programming language.
*
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public Time getTime() {
return getTime(nextConfiguredIndex(), null);
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a java.time.LocalTime
in the Java programming language.
*
* @return the column value; if the value is SQL NULL
, the
* value returned is null
*/
public LocalTime getLocalTime() {
return getLocalTime(nextConfiguredIndex(), null);
}
/**
* Retrieves the value of the designated column in the current row
* of this ResultSet
object as
* a {@link Binary} in the Java programming language.
*
* @param bufSize the initial buffersize for the Binary
* @return the binary read from db
*/
public Binary getBinary(int bufSize) {
try {
return Binary.createBinary(rs.getBinaryStream(nextConfiguredIndex() + columnOffset), bufSize, true);
}
catch (SQLException | IOException e) {
throw new PersistenceException(db, e);
}
}
// ----------------------------------- private methods ----------------------------------------------
/**
* Clears the configured index and sets the flag that cursor was moved.
*/
private void clearSection() {
if (rs == null) {
throw new PersistenceException("result set already closed");
}
currentSection = null;
if (isInSkipMode()) {
cursorMovedInSkipMode = true;
}
}
/**
* Gets the next configured column index.
*
* @return the next column index
*/
private int nextConfiguredIndex() {
assertValidSection();
return currentSection.nextColumnIndex();
}
/**
* Asserts that current section is valid.
*/
private void assertValidSection() {
if (currentSection == null) {
throw new PersistenceException(db, "no current section configured for automatic indexed retrieval");
}
}
/**
* Asserts that result set is in skipmode.
*/
private void assertInSkipMode() {
if (!isInSkipMode()) {
throw new PersistenceException(db, "result set is not in skipmode");
}
}
}