Package com.blackrook.sql
Class SQLRow
java.lang.Object
com.blackrook.sql.SQLRow
SQLRow object.
Represents one row in a query result, mapped using column names.
Contains methods for auto-casting or converting the row data.
-
Method Summary
Modifier and TypeMethodDescriptionbooleangetBoolean(int columnIndex) Gets the boolean value of a column.booleangetBoolean(String columnName) Gets the boolean value of a column.bytegetByte(int columnIndex) Gets the byte value of a column.byteGets the byte value of a column.byte[]getByteArray(int columnIndex) Gets the byte array value of a column, if this can be represented as such (usuallyBlobs).byte[]getByteArray(String columnName) Gets the byte array value of a column, if this can be represented as such (usuallyBlobs).getDate(int columnIndex) Gets the Date value of the object, or null if not a Date.Gets the Date value of the object, or null if not a Date.doublegetDouble(int columnIndex) Gets the double value of a column.doubleGets the double value of a column.floatgetFloat(int columnIndex) Gets the float value of a column.floatGets the float value of a column.intgetInt(int columnIndex) Gets the integer value of a column.intGets the integer value of a column.longgetLong(int columnIndex) Gets the long value of a column.longGets the long value of a column.booleangetNull(int columnIndex) Gets if a column's value is null.booleanGets if a column's value is null.shortgetShort(int columnIndex) Gets the short value of a column.shortGets the short value of a column.getString(int columnIndex) Gets the string value of a column.Gets the string value of a column.getTimestamp(int columnIndex) Gets the Timestamp value of the object, or null if not a Timestamp or Date.getTimestamp(String columnName) Gets the Timestamp value of the object, or null if not a Timestamp or Date.
-
Method Details
-
getNull
public boolean getNull(int columnIndex) Gets if a column's value is null.- Parameters:
columnIndex- the column index to read (0-based).- Returns:
- the resultant value, or null if not a valid column name.
-
getNull
Gets if a column's value is null.- Parameters:
columnName- the column name to read (case-insensitive).- Returns:
- the resultant value, or null if not a valid column name.
-
getBoolean
public boolean getBoolean(int columnIndex) Gets the boolean value of a column. Can convert from Booleans, Numbers, and Strings.- Parameters:
columnIndex- the column index to read (0-based).- Returns:
- the resultant value, or null if not a valid column name.
-
getBoolean
Gets the boolean value of a column. Can convert from Booleans, Numbers, and Strings.- Parameters:
columnName- the column name to read (case-insensitive).- Returns:
- the resultant value, or null if not a valid column name.
-
getByte
public byte getByte(int columnIndex) Gets the byte value of a column. Can convert from Booleans, Numbers, and Strings. Booleans convert to 1 if true, 0 if false.- Parameters:
columnIndex- the column index to read (0-based).- Returns:
- the resultant value, or null if not a valid column name.
-
getByte
Gets the byte value of a column. Can convert from Booleans, Numbers, and Strings. Booleans convert to 1 if true, 0 if false.- Parameters:
columnName- the column name to read (case-insensitive).- Returns:
- the resultant value, or null if not a valid column name.
-
getByteArray
public byte[] getByteArray(int columnIndex) Gets the byte array value of a column, if this can be represented as such (usuallyBlobs). Can convert from Blobs.- Parameters:
columnIndex- the column index to read (0-based).- Returns:
- the resultant value, or null if not a valid column name.
-
getByteArray
Gets the byte array value of a column, if this can be represented as such (usuallyBlobs). Can convert from Blobs.- Parameters:
columnName- the column name to read (case-insensitive).- Returns:
- the resultant value, or null if not a valid column name.
-
getShort
public short getShort(int columnIndex) Gets the short value of a column. Can convert from Booleans, Numbers, and Strings. Booleans convert to 1 if true, 0 if false.- Parameters:
columnIndex- the column index to read (0-based).- Returns:
- the resultant value, or null if not a valid column name.
-
getShort
Gets the short value of a column. Can convert from Booleans, Numbers, and Strings. Booleans convert to 1 if true, 0 if false.- Parameters:
columnName- the column name to read (case-insensitive).- Returns:
- the resultant value, or null if not a valid column name.
-
getInt
public int getInt(int columnIndex) Gets the integer value of a column. Can convert from Booleans, Numbers, and Strings. Booleans convert to 1 if true, 0 if false.- Parameters:
columnIndex- the column index to read (0-based).- Returns:
- the resultant value, or null if not a valid column name.
-
getInt
Gets the integer value of a column. Can convert from Booleans, Numbers, and Strings. Booleans convert to 1 if true, 0 if false.- Parameters:
columnName- the column name to read (case-insensitive).- Returns:
- the resultant value, or null if not a valid column name.
-
getFloat
public float getFloat(int columnIndex) Gets the float value of a column. Can convert from Booleans, Numbers, and Strings. Booleans convert to 1 if true, 0 if false.- Parameters:
columnIndex- the column index to read (0-based).- Returns:
- the resultant value, or null if not a valid column name.
-
getFloat
Gets the float value of a column. Can convert from Booleans, Numbers, and Strings. Booleans convert to 1 if true, 0 if false.- Parameters:
columnName- the column name to read (case-insensitive).- Returns:
- the resultant value, or null if not a valid column name.
-
getLong
public long getLong(int columnIndex) Gets the long value of a column. Can convert from Booleans, Numbers, Strings, and Dates/Timestamps. Booleans convert to 1 if true, 0 if false. Dates and Timestamps convert to milliseconds since the Epoch.- Parameters:
columnIndex- the column index to read (0-based).- Returns:
- the resultant value, or null if not a valid column name.
-
getLong
Gets the long value of a column. Can convert from Booleans, Numbers, Strings, and Dates/Timestamps. Booleans convert to 1 if true, 0 if false. Dates and Timestamps convert to milliseconds since the Epoch.- Parameters:
columnName- the column name to read (case-insensitive).- Returns:
- the resultant value, or null if not a valid column name.
-
getDouble
public double getDouble(int columnIndex) Gets the double value of a column. Can convert from Booleans, Numbers, and Strings. Booleans convert to 1 if true, 0 if false.- Parameters:
columnIndex- the column index to read (0-based).- Returns:
- the resultant value, or null if not a valid column name.
-
getDouble
Gets the double value of a column. Can convert from Booleans, Numbers, and Strings. Booleans convert to 1 if true, 0 if false.- Parameters:
columnName- the column name to read (case-insensitive).- Returns:
- the resultant value, or null if not a valid column name.
-
getString
Gets the string value of a column. Can convert from Booleans, Numbers, byte and char arrays, Blobs, and Clobs. Booleans convert to 1 if true, 0 if false. Byte arrays and Blobs are converted using the native charset encoding. Char arrays and Clobs are read entirely and converted to Strings.- Parameters:
columnIndex- the column index to read (0-based).- Returns:
- the resultant value, or null if not a valid column name.
- See Also:
-
getString
Gets the string value of a column. Can convert from Booleans, Numbers, byte and char arrays, Blobs, and Clobs. Booleans convert to 1 if true, 0 if false. Byte arrays and Blobs are converted using the native charset encoding. Char arrays and Clobs are read entirely and converted to Strings.- Parameters:
columnName- the column name to read (case-insensitive).- Returns:
- the resultant value, or null if not a valid column name.
- See Also:
-
getTimestamp
Gets the Timestamp value of the object, or null if not a Timestamp or Date.- Parameters:
columnIndex- the column index to read (0-based).- Returns:
- the resultant value, or null if not a valid column name.
-
getTimestamp
Gets the Timestamp value of the object, or null if not a Timestamp or Date.- Parameters:
columnName- the column name to read (case-insensitive).- Returns:
- the resultant value, or null if not a valid column name.
-
getDate
Gets the Date value of the object, or null if not a Date.- Parameters:
columnIndex- the column index to read (0-based).- Returns:
- the resultant value, or null if not a valid column name.
-
getDate
Gets the Date value of the object, or null if not a Date.- Parameters:
columnName- the column name to read (case-insensitive).- Returns:
- the resultant value, or null if not a valid column name.
-