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 TypeMethodDescriptionboolean
getBoolean
(int columnIndex) Gets the boolean value of a column.boolean
getBoolean
(String columnName) Gets the boolean value of a column.byte
getByte
(int columnIndex) Gets the byte value of a column.byte
Gets 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 (usuallyBlob
s).byte[]
getByteArray
(String columnName) Gets the byte array value of a column, if this can be represented as such (usuallyBlob
s).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.double
getDouble
(int columnIndex) Gets the double value of a column.double
Gets the double value of a column.float
getFloat
(int columnIndex) Gets the float value of a column.float
Gets the float value of a column.int
getInt
(int columnIndex) Gets the integer value of a column.int
Gets the integer value of a column.long
getLong
(int columnIndex) Gets the long value of a column.long
Gets the long value of a column.boolean
getNull
(int columnIndex) Gets if a column's value is null.boolean
Gets if a column's value is null.short
getShort
(int columnIndex) Gets the short value of a column.short
Gets 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 (usuallyBlob
s). 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 (usuallyBlob
s). 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.
-