Package com.basiscomponents.db
Class ResultSet
- java.lang.Object
-
- com.basiscomponents.db.ResultSet
-
- All Implemented Interfaces:
Serializable
,Iterable<DataRow>
public class ResultSet extends Object implements Serializable, Iterable<DataRow>
The ResultSet class is a container class for DataRow objects.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static int
NO_SORT
static int
SORT_ON_GROUPFIELD
static int
SORT_ON_GROUPFIELD_DESC
static int
SORT_ON_GROUPLABEL
static int
SORT_ON_GROUPLABEL_DESC
static int
SORT_ON_RESULT
static int
SORT_ON_RESULT_DESC
-
Constructor Summary
Constructors Constructor Description ResultSet()
ResultSet(ResultSet rs)
Initializes the ResultSet using the metadata and Data from the given java.sql.ResultSet.ResultSet(List<HashMap<String,Object>> metaData, List<String> columnNames, List<DataRow> dataRows, List<String> keyColumns)
ResultSet(List<HashMap<String,Object>> metaData, List<String> columnNames, List<String> keyColumns)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
absolute(int row)
Moves the cursor to the DataRow element at the specified index.void
add(int row, DataRow dr)
Inserts the given DataRow object at the specified index in the ResultSet.void
add(DataRow dr)
Adds the given DataRow object to the ResultSet.int
addColumn(String name)
Adds a column with the specified name to the list of columns.int
addColumn(String name, HashMap<String,Object> colMap)
Adds a column with the given name and the given metadata to the list of columns.void
addItem(DataRow dr)
Adds the given DataRow object to the ResultSet.void
addKeyColumn(String name)
Sets the given column name as key column.void
afterLast()
Moves the cursor after the last DataRow element.Double
avg(String fieldname)
Returns the average value of all fields with the specified name, by iterating over all DataRow objects of this ResultSet.void
beforeFirst()
Moves the cursor before the first DataRow element.void
buildRowKey(ResultSet rs, DataRow dr)
void
clear()
Clears the ResultSet by removing all DataRow objects.void
clearConversionRuleSet()
Clears a global conversion rule setResultSet
clone()
ResultSet
clone(Boolean fDeepClone)
creates a clone of the ResultSetint
count()
Returns the number of DataRows stored in this ResultSet.DataRow
countByGroup(String fieldname)
Returns a DataRow which contains all field values of the DataRows defined in this ResultSet for the given field name.DataRow
countByGroup(String fieldname, String labelname)
Returns a DataRow which contains all field values of the DataRows defined in this ResultSet for the given field name.DataRow
countByGroup(String fieldname, String labelname, int sort, int top)
Returns a DataRow which contains all field values of the DataRows defined in this ResultSet for the given field name.void
createIndex()
ResultSet
filterBy(DataRow simpleFilterCondition)
Search for DataRow(s) containing a specific value(s) Returns a new ResultSet with the DataRow(s) found in the current instance.ResultSet
filterBy(String queryClause)
Applies the queryClause to a ResultSet and returns a new ResultSet that only contains records that match the clause.ResultSet
filterBy(String QueryClause, boolean caseSensitive, boolean trimmed)
Applies the queryClause to a ResultSet and returns a new ResultSet that only contains records that match the clause.Boolean
first()
Moves the cursor to the first DataRow element of this ResultSet.static ResultSet
fromJson(String js)
Returns a ResultSet object created by parsing the given JSON String.DataRow
get(int row)
Returns the DataRow at the given index.DataRow
get(String rowkey)
Returns the DataRow with the given row key.Array
getArray(int column)
Retrieves the DataField object of the current DataRow for the specified column index, and returns the DataField's value object as Array.String
getAttribute(int column, String name)
Returns the attribute with the given name, for the column at the specified index.String
getAttribute(String columnName, String attributeName)
Returns the attribute with the given name, for the column at the specified index.String
getBBTemplate()
Creates and returns simplified BB template definition based on result set metadata, analog SQLTMPL().String
getBBTemplate(Boolean extendedInfo)
Creates and returns BB template definition based on ResultSetMeatData, analog SQLTMPL().BigDecimal
getBigDecimal(int column)
Retrieves the DataField object of the current DataRow for the specified column index, and returns the DataField's value object as BigDecimal.Blob
getBlob(int column)
Retrieves the DataField object of the current DataRow for the specified column index, and returns the DataField's value object as Blob.Boolean
getBoolean(int column)
Retrieves the DataField object of the current DataRow for the specified column index, and returns the DataField's value object as Boolean.Byte
getByte(int column)
Retrieves the DataField object of the current DataRow for the specified column index, and returns the DataField's value object as Byte.byte[]
getBytes(int column)
Retrieves the DataField object of the current DataRow for the specified column index, and returns the DataField's value object as Byte array.String
getCatalogName(int column)
Returns the value of the CatalogName property from the ResultSet's metadata, for the column at the specified index.Clob
getClob(int column)
Retrieves the DataField object of the current DataRow for the specified column index, and returns the DataField's value object as Clob.String
getColumnClassName(int column)
Returns the value of the ColumnClassName property from the ResultSet's metadata, for the column at the specified index.int
getColumnCount()
Returns the number of columns.int
getColumnDisplaySize(int column)
Returns the value of the ColumnDisplaySize property from the ResultSet's metadata, for the column at the specified index.int
getColumnIndex(String name)
Returns the index of the column with the specified name, or -1 in case no column exists for the given name.String
getColumnLabel(int column)
Returns the value of the ColumnLabel property from the ResultSet's metadata, for the column at the specified index.HashMap<String,Object>
getColumnMetaData(String name)
Returns the metadata of the column with the specified name.String
getColumnName(int column)
Returns the value of the ColumnName property from the ResultSet's metadata, for the column at the specified index.ArrayList<String>
getColumnNames()
Returns a list with all column names.int
getColumnType(int column)
Returns the value of the ColumnType property from the ResultSet's metadata, for the column at the specified index.String
getColumnTypeName(int column)
Returns the value of the ColumnTypeName property from the ResultSet's metadata, for the column at the specified index.ConversionRuleSet
getConversionRuleSet()
ArrayList<DataRow>
getDataRows()
Date
getDate(int column)
Retrieves the DataField object of the current DataRow for the specified column index, and returns the DataField's value object as Date.Double
getDouble(int column)
Retrieves the DataField object of the current DataRow for the specified column index, and returns the DataField's value object as Double.DataField
getField(int column)
Returns the DataField object of the current DataRow for the specified column index.Float
getFloat(int column)
Retrieves the DataField object of the current DataRow for the specified column index, and returns the DataField's value object as Float.Integer
getInt(int column)
Retrieves the DataField object of the current DataRow for the specified column index, and returns the DataField's value object as Integer.DataRow
getItem(int row)
Returns the DataRow at the given index.ArrayList<String>
getKeyColumns()
Returns a list with all key columns.String
getKeyTemplate()
Long
getLong(int column)
Retrieves the DataField object of the current DataRow for the specified column index, and returns the DataField's value object as Long.ArrayList<HashMap<String,Object>>
getMetaData()
Clob
getNClob(int column)
Retrieves the DataField object of the current DataRow for the specified column index, and returns the DataField's value object as NClob.String
getNString(int column)
Retrieves the DataField object of the current DataRow for the specified column index, and returns the DataField's value object as NString.Object
getObject(int column)
Retrieves the DataField object of the current DataRow for the specified column index, and returns the DataField's value object.int
getPrecision(int column)
Returns the value of the Precision property from the ResultSet's metadata, for the column at the specified index.Ref
getRef(int column)
Retrieves the DataField object of the current DataRow for the specified column index, and returns the DataField's value object as Ref.int
getRow()
Returns the current DataRow.String
getRowKey()
Returns the row key of the current DataRow object.String
getRowKey(int row)
int
getScale(int column)
Returns the value of the Scale property from the ResultSet's metadata, for the column at the specified index.String
getSchemaName(int column)
Returns the value of the SchemaName property from the ResultSet's metadata, for the column at the specified index.Short
getShort(int column)
Retrieves the DataField object of the current DataRow for the specified column index, and returns the DataField's value object as Short.ResultSet
getSQLResultSet()
Returns the java.sql.ResultSet object of this com.basiscomponents.db.ResultSet object.static String
getSQLTypeName(int sqlType)
Returns the name of the given java.sql.Type value, or null in case the given type is unknown.String
getString(int column)
Retrieves the DataField object of the current DataRow for the specified column index, and returns the DataField's value object as String.String
getTableName(int column)
Returns the value of the TableName property from the ResultSet's metadata, for the column at the specified index.Time
getTime(int column)
Retrieves the DataField object of the current DataRow for the specified column index, and returns the DataField's value object as Time.Timestamp
getTimestamp(int column)
Retrieves the DataField object of the current DataRow for the specified column index, and returns the DataField's value object as Timestamp.URL
getURL(int column)
Retrieves the DataField object of the current DataRow for the specified column index, and returns the DataField's value object as URL.int
indexOf(DataRow row)
returns the zero-based index of a row in the ResultSet if the ResultSet is indexed and the DataRow contains a rowKey, then the rowKey is used for finding the record in the index.int
indexOf(String rowKey)
returns the zero-based index of a row in the ResultSet if the ResultSet is indexed and the DataRow contains a rowKey, then the rowKey is used for finding the record in the index.void
insertItem(int row, DataRow dr)
Inserts the given DataRow object at the specified index in the ResultSet.Boolean
isAutoIncrement(int column)
Returns the value of the AutoIncrement property from the ResultSet's metadata, for the column at the specified index.Boolean
isCaseSensitive(int column)
Returns the value of the CaseSensitive property from the ResultSet's metadata, for the column at the specified index.Boolean
isCurrency(int column)
Returns the value of the Currency property from the ResultSet's metadata, for the column at the specified index.Boolean
isDefinitelyWritable(int column)
Returns the value of the DefinitelyWritable property from the ResultSet's metadata, for the column at the specified index.Boolean
isEmpty()
Returns true if the ResultSet doesn't contain any DataRow, false otherwise.Boolean
isIndexed()
isIndexed: check if the ResultSet has an internal index row that would allow access by a key instead of the numeric integer indexboolean
isNull(int column)
Checks a DataField for nullint
isNullable(int column)
Returns the value of the Nullable property from the ResultSet's metadata, for the column at the specified index.Boolean
isReadOnly(int column)
Returns the value of the ReadOnly property from the ResultSet's metadata, for the column at the specified index.Boolean
isSearchable(int column)
Returns the value of the Searchable property from the ResultSet's metadata, for the column at the specified index.Boolean
isSigned(int column)
Returns the value of the Signed property from the ResultSet's metadata, for the column at the specified index.Boolean
isWritable(int column)
Returns the value of the Writable property from the ResultSet's metadata, for the column at the specified index.Iterator<DataRow>
iterator()
Boolean
last()
Moves the cursor to the last DataRow element of this ResultSet.Double
max(String fieldname)
Returns the max value of all fields with the specified name, by iterating over all DataRow objects of this ResultSet.Double
median(String fieldname)
Returns the median value of all fields with the specified name, by iterating over all DataRow objects of this ResultSet.void
merge(ResultSet rs2, String onFieldName, boolean fOverwrite)
Double
min(String fieldname)
Returns the min value of all fields with the specified name, by iterating over all DataRow objects of this ResultSet.boolean
next()
Moves the cursor to the next DataRow element.ResultSet
orderBy(String orderByClause)
re-orders a result set according to an ORDER BY clause like in SQL ORDER BY: e.g.void
orderByColumn(String fieldName, String direction)
Re-orders the ResultSet based on the given field name and the given sort direction.void
orderByColumn(Comparator<DataRow> comparator)
Re-order the ResultSet using the given Comparator object.void
orderByRowID()
Re-orders the ResultSet based on the Row ID's.void
populate(ResultSet rs, Boolean defaultMetaData)
Iterates over the givenjava.sql.ResultSet
object and adds a DataRow object for each record of it to this ResultSet.void
print()
void
reCreateIndex()
void
registerResultSetListener(ResultSetListener mListener)
DataRow
remove(int row)
Removes the DataRow at the specified index, and shifts any subsequent DataRows to the left.DataRow
remove(String rowkey)
Removes the DataRowspecified by key, and shifts any subsequent DataRows to the left.void
removeColumn(int column)
Removes the column at the given index.void
removeColumn(String name)
Removes the column with the given name.DataRow
removeItem(int row)
Removes the DataRow at the specified index, and shifts any subsequent DataRows to the left.void
set(int row, DataRow dr)
Sets the DataRow at the given index.void
setAttribute(int column, String name, String value)
Sets the attribute with the specified name and value to the column at the specified index.void
setAttribute(String columnName, String name, String value)
Sets the attribute with the specified name and value to the column at the specified index.void
setAutoIncrement(int column, Boolean flag)
Sets the value of the AutoIncrement property of the ResultSet's metadata to the given value, for the column at the specified index.void
setCaseSensitive(int column, Boolean flag)
Sets the value of the CaseInsensitive property of the ResultSet's metadata to the given value, for the column at the specified index.void
setCatalogName(int column, String catalogName)
Sets the value of the CatalogName property of the ResultSet's metadata to the given value, for the column at the specified index.void
setColumnClassName(int column, String className)
Sets the value of the ColumnClassName property of the ResultSet's metadata to the given value, for the column at the specified index.void
setColumnDisplaySize(int column, int displaySize)
Sets the value of the ColumnDisplaySize property of the ResultSet's metadata to the given value, for the column at the specified index.void
setColumnLabel(int column, String label)
Sets the value of the ColumnLabel property of the ResultSet's metadata to the given value, for the column at the specified index.void
setColumnMetaData(String name, HashMap<String,Object> colMap)
Sets the given metadata to the column with the specified name.void
setColumnName(int column, String name)
Sets the value of the ColumnName property of the ResultSet's metadata to the given value, for the column at the specified index.void
setColumnType(int column, int type)
Sets the value of the ColumnType property of the ResultSet's metadata to the given value, for the column at the specified index.void
setColumnTypeName(int column, String typeName)
Sets the value of the ColumnTypeName property of the ResultSet's metadata to the given value, for the column at the specified index.void
setConversionRuleSet(ConversionRuleSet crs)
Sets a global conversion rule set which is honored for standard output methods, like print and toJson.void
setCurrency(int column, Boolean flag)
Sets the value of the Currency property of the ResultSet's metadata to the given value, for the column at the specified index.void
setDefinitelyWritable(int column, Boolean flag)
Sets the value of the DefinitelyWritable property of the ResultSet's metadata to the given value, for the column at the specified index.void
setFieldSelection(List<String> fieldSelection)
Sets the list of field names to be imported into the ResultSet when calling thepopulate(java.sql.ResultSet, Boolean)
method.void
setItem(int row, DataRow dr)
Sets the DataRow at the given index.void
setKeyColumns(ArrayList<String> keyColumns)
void
setKeyTemplate(String template)
void
setNullable(int column, int nullable)
Sets the value of the DefinitelyWritable property of the ResultSet's metadata to the given value, for the column at the specified index.void
setPrecision(int column, int precision)
Sets the value of the Precision property of the ResultSet's metadata to the given value, for the column at the specified index.void
setReadOnly(int column, Boolean flag)
Sets the value of the ReadOnly property of the ResultSet's metadata to the given value, for the column at the specified index.void
setScale(int column, int scale)
Sets the value of the Scale property of the ResultSet's metadata to the given value, for the column at the specified index.void
setSchemaName(int column, String schemaName)
Sets the value of the SchemaName property of the ResultSet's metadata to the given value, for the column at the specified index.void
setSearchable(int column, Boolean flag)
Sets the value of the Searchable property of the ResultSet's metadata to the given value, for the column at the specified index.void
setSigned(int column, Boolean flag)
Sets the value of the Signed property of the ResultSet's metadata to the given value, for the column at the specified index.void
setTableName(int column, String tableName)
Sets the value of the TableName property of the ResultSet's metadata to the given value, for the column at the specified index.void
setWritable(int column, Boolean flag)
Sets the value of the Writable property of the ResultSet's metadata to the given value, for the column at the specified index.int
size()
Returns the number of DataRows stored in the ResultSet.Double
sum(String fieldname)
Returns the sum of all fields with the specified name, by iterating over all DataRow objects of this ResultSet.DataRow
sumByGroup(String fieldname, String sumfieldname)
Returns a DataRow which contains all field values of the DataRows defined in this ResultSet for the given field name.DataRow
sumByGroup(String fieldname, String labelname, String sumfieldname, int sort, int top)
Returns a DataRow which contains all field values of the DataRows defined in this ResultSet for the given field name.net.sf.jasperreports.engine.JRDataSource
toJRDataSource()
Returns this ResultSet as a JRDataSourceString
toJson()
Returns a JSON String with the ResultSet's content.String
toJson(boolean meta, String addIndexColumn, boolean trimStrings)
String
toJson(boolean meta, String addIndexColumn, boolean trimStrings, boolean writeDataRowAttributes)
String
toJson(Boolean f_meta)
Returns a JSON String with the ResultSet's content.String
toJson(Boolean f_meta, String addIndexColumn)
Returns a JSON String with the ResultSet's content.Object
toJsonElement()
Returns this ResultSet as com.google.gson.JsonArray object.String
toString()
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Field Detail
-
NO_SORT
public static final int NO_SORT
- See Also:
- Constant Field Values
-
SORT_ON_GROUPFIELD
public static final int SORT_ON_GROUPFIELD
- See Also:
- Constant Field Values
-
SORT_ON_GROUPLABEL
public static final int SORT_ON_GROUPLABEL
- See Also:
- Constant Field Values
-
SORT_ON_RESULT
public static final int SORT_ON_RESULT
- See Also:
- Constant Field Values
-
SORT_ON_GROUPFIELD_DESC
public static final int SORT_ON_GROUPFIELD_DESC
- See Also:
- Constant Field Values
-
SORT_ON_GROUPLABEL_DESC
public static final int SORT_ON_GROUPLABEL_DESC
- See Also:
- Constant Field Values
-
SORT_ON_RESULT_DESC
public static final int SORT_ON_RESULT_DESC
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ResultSet
public ResultSet()
-
ResultSet
public ResultSet(List<HashMap<String,Object>> metaData, List<String> columnNames, List<DataRow> dataRows, List<String> keyColumns)
-
ResultSet
public ResultSet(List<HashMap<String,Object>> metaData, List<String> columnNames, List<String> keyColumns)
-
ResultSet
public ResultSet(ResultSet rs)
Initializes the ResultSet using the metadata and Data from the given java.sql.ResultSet.- Parameters:
rs
- The java.sql.ResultSet used to initialize the ResultSet object.
-
-
Method Detail
-
clone
public ResultSet clone(Boolean fDeepClone)
creates a clone of the ResultSet- Parameters:
fDeepClone
- set to true to also clone all the DataRows contained, false will only clone the container but both will continue to reference the same DataRows- Returns:
-
orderBy
public ResultSet orderBy(String orderByClause) throws Exception
re-orders a result set according to an ORDER BY clause like in SQL ORDER BY: e.g. (ORDER BY) NAME, FIRST_NAME DESC, ZIP NOTE: Only ASC and DESC are allowed!- Parameters:
orderByClause
- : order by clause- Returns:
- the ordered result set
- Throws:
Exception
-
orderByColumn
public void orderByColumn(String fieldName, String direction)
Re-orders the ResultSet based on the given field name and the given sort direction. The sort direction can only be ASC(=Ascending) or DESC(=Descending). If any value is passed which is not "ASC" or "DESC", the methods defaults to the ascending sorting.- Parameters:
fieldName
- The field name on which to sort the ResultSetdirection
- The sort direction("ASC" or "DESC")
-
orderByColumn
public void orderByColumn(Comparator<DataRow> comparator)
Re-order the ResultSet using the given Comparator object.- Parameters:
comparator
- The comparator used to re-order the ResultSet.
-
orderByRowID
public void orderByRowID()
Re-orders the ResultSet based on the Row ID's. This methods can be used to revert the ResultSet's order back to its default.
Note: The method does nothing in case the ResultSet hasn't been reordered.
-
filterBy
public ResultSet filterBy(String queryClause) throws Exception
Applies the queryClause to a ResultSet and returns a new ResultSet that only contains records that match the clause. The clause syntax is similar to an SQL WHERE clause. CAUTION: this method is experimental!! It only understands "equals" and basic statements, no full SQL. Searching for volunteers to implant full SQL where clause parsing.- Parameters:
queryClause
- : the query- Returns:
- ResultSet: the records that match the query clause
- Throws:
Exception
-
filterBy
public ResultSet filterBy(String QueryClause, boolean caseSensitive, boolean trimmed) throws Exception
Applies the queryClause to a ResultSet and returns a new ResultSet that only contains records that match the clause. The clause syntax is similar to an SQL WHERE clause. CAUTION: this method is experimental!! It only understands "equals" and basic statements, no full SQL. Searching for volunteers to implant full SQL where clause parsing.- Parameters:
QueryClause
- : the querycaseSensitive
- whether the filter query should be case sensitive or nottrimmed
-true
if the query paramters should get trimmed- Returns:
- ResultSet: the records that match the query clause
- Throws:
Exception
-
filterBy
public ResultSet filterBy(DataRow simpleFilterCondition) throws Exception
Search for DataRow(s) containing a specific value(s) Returns a new ResultSet with the DataRow(s) found in the current instance. If the type of field in simpleFilterCondition is 12 (String) and the value starts with "regex:" then a regular search will be applied- Parameters:
simpleFilterCondition
- A DataRow with the vlaues to search for.- Returns:
- a ResultSet with the DataRows found in the current instance.
- Throws:
Exception
-
registerResultSetListener
public void registerResultSetListener(ResultSetListener mListener)
-
populate
public void populate(ResultSet rs, Boolean defaultMetaData) throws Exception
Iterates over the givenjava.sql.ResultSet
object and adds a DataRow object for each record of it to this ResultSet. If the defaultMetaData flag is set to true, the ResultSet will use the metadata from the given java.sql.ResultSet object. If it is set to false, no metadata will be created. If the resultSet already has some metadata defined, it will not be removed. In case the field selection list has been set, this method will only create DataRow object's with the fields from the field selection list.- Parameters:
rs
-defaultMetaData
-- Throws:
Exception
-
add
public void add(DataRow dr)
Adds the given DataRow object to the ResultSet.- Parameters:
dr
- The DataRow to add.
-
add
public void add(int row, DataRow dr)
Inserts the given DataRow object at the specified index in the ResultSet.- Parameters:
row
- The index were to insert the DataRow.dr
- The DataRow to insert.
-
addItem
public void addItem(DataRow dr)
Adds the given DataRow object to the ResultSet.- Parameters:
dr
- The DataRow to add.
-
insertItem
public void insertItem(int row, DataRow dr)
Inserts the given DataRow object at the specified index in the ResultSet.- Parameters:
row
- The index were to insert the DataRow.dr
- The DataRow to insert.
-
addColumn
public int addColumn(String name)
Adds a column with the specified name to the list of columns.- Parameters:
name
- The name of the column.- Returns:
- the index of the newly added column.
-
addColumn
public int addColumn(String name, HashMap<String,Object> colMap)
Adds a column with the given name and the given metadata to the list of columns.- Parameters:
name
- The name of the column.colMap
- The metadata for the column.- Returns:
- the index of the newly added column.
-
setColumnMetaData
public void setColumnMetaData(String name, HashMap<String,Object> colMap)
Sets the given metadata to the column with the specified name.- Parameters:
name
- The name of the column.colMap
- The metadata to set.
-
getColumnMetaData
public HashMap<String,Object> getColumnMetaData(String name)
Returns the metadata of the column with the specified name.- Parameters:
name
- The name of the column.- Returns:
- the column's metadata.
-
getColumnIndex
public int getColumnIndex(String name)
Returns the index of the column with the specified name, or -1 in case no column exists for the given name.- Parameters:
name
- The name of the column.- Returns:
- the column's index or -1 if the column doesn't exist.
-
getColumnNames
public ArrayList<String> getColumnNames()
Returns a list with all column names.- Returns:
- the list with all column names.
-
getKeyColumns
public ArrayList<String> getKeyColumns()
Returns a list with all key columns.- Returns:
- the list with the key columns.
-
setKeyColumns
public void setKeyColumns(ArrayList<String> keyColumns) throws ParseException
- Parameters:
keyColumns
- the keyColumns to set- Throws:
ParseException
-
addKeyColumn
public void addKeyColumn(String name)
Sets the given column name as key column.- Parameters:
name
- the name of the key column to add.
-
getKeyTemplate
public String getKeyTemplate()
- Returns:
- the template definition string
-
setKeyTemplate
public void setKeyTemplate(String template)
- Parameters:
template
- the template definition string
-
getRowKey
public String getRowKey()
Returns the row key of the current DataRow object.- Returns:
- key data as a string for the current row
-
getRowKey
public String getRowKey(int row)
- Returns:
- key data as a string for a specific row
-
indexOf
public int indexOf(DataRow row)
returns the zero-based index of a row in the ResultSet if the ResultSet is indexed and the DataRow contains a rowKey, then the rowKey is used for finding the record in the index. Else the routine iterates the ResultSet and performs an .equals on each DataRow to see if there is a match based on the field contents.- Parameters:
row
- - the row for which the index is desired- Returns:
- - the index of the DataRow in the ResultSet, or -1 if no match is found
-
indexOf
public int indexOf(String rowKey)
returns the zero-based index of a row in the ResultSet if the ResultSet is indexed and the DataRow contains a rowKey, then the rowKey is used for finding the record in the index. Else the routine iterates the ResultSet and performs an .equals on each DataRow to see if there is a match based on the field contents.- Parameters:
rowKey
- - the rowKey as String for which the index is desired- Returns:
- - the index of the DataRow in the ResultSet, or -1 if no match is found
-
clear
public void clear()
Clears the ResultSet by removing all DataRow objects.
-
get
public DataRow get(String rowkey) throws Exception
Returns the DataRow with the given row key.- Parameters:
rowkey
- The index of the DataRow.- Returns:
- The DataRow at the specified index.
- Throws:
Exception
-
get
public DataRow get(int row)
Returns the DataRow at the given index.- Parameters:
row
- The index of the DataRow.- Returns:
- The DataRow at the specified index.
-
getItem
public DataRow getItem(int row)
Returns the DataRow at the given index.- Parameters:
row
- The index of the DataRow.- Returns:
- The DataRow at the specified index.
-
set
public void set(int row, DataRow dr) throws ParseException
Sets the DataRow at the given index.- Parameters:
row
- The index of the DataRow.dr
- The DataRow to set.- Throws:
ParseException
-
setItem
public void setItem(int row, DataRow dr) throws ParseException
Sets the DataRow at the given index.- Parameters:
row
- The index of the DataRow.dr
- The DataRow to set.- Throws:
ParseException
-
getRow
public int getRow()
Returns the current DataRow.- Returns:
- the current DataRow object.
-
isEmpty
public Boolean isEmpty()
Returns true if the ResultSet doesn't contain any DataRow, false otherwise.- Returns:
- true if the ResultSet doesn't have any DataRows, false otherwise.
-
remove
public DataRow remove(String rowkey) throws Exception
Removes the DataRowspecified by key, and shifts any subsequent DataRows to the left.- Parameters:
rowkey
- The key of the DataRow to remove.- Returns:
- The DataRow that was removed.
- Throws:
Exception
-
remove
public DataRow remove(int row)
Removes the DataRow at the specified index, and shifts any subsequent DataRows to the left.- Parameters:
row
- The index of the DataRow to remove.- Returns:
- The DataRow that was removed.
-
removeItem
public DataRow removeItem(int row)
Removes the DataRow at the specified index, and shifts any subsequent DataRows to the left.- Parameters:
row
- The index of the DataRow to remove.- Returns:
- The DataRow that was removed.
-
removeColumn
public void removeColumn(int column)
Removes the column at the given index.- Parameters:
column
- The column index
-
removeColumn
public void removeColumn(String name)
Removes the column with the given name.- Parameters:
name
- The column name
-
size
public int size()
Returns the number of DataRows stored in the ResultSet.- Returns:
- The number of DataRow objects stored in the ResultSet.
-
beforeFirst
public void beforeFirst()
Moves the cursor before the first DataRow element.
-
afterLast
public void afterLast()
Moves the cursor after the last DataRow element.
-
first
public Boolean first()
Moves the cursor to the first DataRow element of this ResultSet. Returns true if the cursor was successfully moved at the first element, false otherwise.- Returns:
- true if the cursor was successfully moved to the first element, false otherwise.
-
last
public Boolean last()
Moves the cursor to the last DataRow element of this ResultSet. Returns true if the cursor was successfully moved at the last element, false otherwise.- Returns:
- true if the cursor was successfully moved to the last element, false otherwise.
-
absolute
public boolean absolute(int row)
Moves the cursor to the DataRow element at the specified index. Returns true if the cursor was successfully moved to the specified index, false otherwise.- Returns:
- true if the cursor was successfully moved to the specified index, false otherwise.
-
next
public boolean next()
Moves the cursor to the next DataRow element. Returns true if the cursor was moved successfully, false otherwise.- Returns:
- true if the cursor was moved successfully, false otherwise.
-
getColumnCount
public int getColumnCount()
Returns the number of columns.- Returns:
- the number of columns.
-
getCatalogName
public String getCatalogName(int column)
Returns the value of the CatalogName property from the ResultSet's metadata, for the column at the specified index. Returns an empty String in case the property isn't set.- Parameters:
column
- The column index.- Returns:
- The value of the CatalogName property of the column.
-
getColumnClassName
public String getColumnClassName(int column)
Returns the value of the ColumnClassName property from the ResultSet's metadata, for the column at the specified index. Returns an empty String in case the property isn't set.- Parameters:
column
- The column index.- Returns:
- The value of the ColumnClassName property of the column.
-
getColumnDisplaySize
public int getColumnDisplaySize(int column)
Returns the value of the ColumnDisplaySize property from the ResultSet's metadata, for the column at the specified index. Returns an empty String in case the property isn't set.- Parameters:
column
- The column index.- Returns:
- The value of the ColumnDisplaySize property of the column.
-
getColumnLabel
public String getColumnLabel(int column)
Returns the value of the ColumnLabel property from the ResultSet's metadata, for the column at the specified index. Returns an empty String in case the property isn't set.- Parameters:
column
- The column index.- Returns:
- The value of the ColumnLabel property of the column.
-
getColumnName
public String getColumnName(int column)
Returns the value of the ColumnName property from the ResultSet's metadata, for the column at the specified index. Returns an empty String in case the property isn't set.- Parameters:
column
- The column index.- Returns:
- The value of the ColumnName property of the column.
-
getColumnType
public int getColumnType(int column)
Returns the value of the ColumnType property from the ResultSet's metadata, for the column at the specified index. Returns 0 in case the property isn't set.- Parameters:
column
- The column index.- Returns:
- The value of the ColumnType property of the column.
-
getColumnTypeName
public String getColumnTypeName(int column)
Returns the value of the ColumnTypeName property from the ResultSet's metadata, for the column at the specified index. Returns an empty String in case the property isn't set.- Parameters:
column
- The column index.- Returns:
- The value of the ColumnTypeName property of the column.
-
getPrecision
public int getPrecision(int column)
Returns the value of the Precision property from the ResultSet's metadata, for the column at the specified index. Returns an empty String in case the property isn't set.- Parameters:
column
- The column index.- Returns:
- The value of the Precision property of the column.
-
getScale
public int getScale(int column)
Returns the value of the Scale property from the ResultSet's metadata, for the column at the specified index. Returns an empty String in case the property isn't set.- Parameters:
column
- The column index.- Returns:
- The value of the Scale property of the column.
-
getSchemaName
public String getSchemaName(int column)
Returns the value of the SchemaName property from the ResultSet's metadata, for the column at the specified index. Returns an empty String in case the property isn't set.- Parameters:
column
- The column index.- Returns:
- The value of the SchemaName property of the column.
-
getTableName
public String getTableName(int column)
Returns the value of the TableName property from the ResultSet's metadata, for the column at the specified index. Returns an empty String in case the property isn't set.- Parameters:
column
- The column index.- Returns:
- The value of the TableName property of the column.
-
isAutoIncrement
public Boolean isAutoIncrement(int column)
Returns the value of the AutoIncrement property from the ResultSet's metadata, for the column at the specified index. Returns an empty String in case the property isn't set.- Parameters:
column
- The column index.- Returns:
- The value of the AutoIncrement property of the column.
-
isCaseSensitive
public Boolean isCaseSensitive(int column)
Returns the value of the CaseSensitive property from the ResultSet's metadata, for the column at the specified index. Returns an empty String in case the property isn't set.- Parameters:
column
- The column index.- Returns:
- The value of the CaseSensitive property of the column.
-
isCurrency
public Boolean isCurrency(int column)
Returns the value of the Currency property from the ResultSet's metadata, for the column at the specified index. Returns an empty String in case the property isn't set.- Parameters:
column
- The column index.- Returns:
- The value of the Currency property of the column.
-
isDefinitelyWritable
public Boolean isDefinitelyWritable(int column)
Returns the value of the DefinitelyWritable property from the ResultSet's metadata, for the column at the specified index. Returns an empty String in case the property isn't set.- Parameters:
column
- The column index.- Returns:
- The value of the DefinitelyWritable property of the column.
-
isNullable
public int isNullable(int column)
Returns the value of the Nullable property from the ResultSet's metadata, for the column at the specified index. Returns an empty String in case the property isn't set.- Parameters:
column
- The column index.- Returns:
- The value of the Nullable property of the column.
-
isReadOnly
public Boolean isReadOnly(int column)
Returns the value of the ReadOnly property from the ResultSet's metadata, for the column at the specified index. Returns an empty String in case the property isn't set.- Parameters:
column
- The column index.- Returns:
- The value of the ReadOnly property of the column.
-
isSearchable
public Boolean isSearchable(int column)
Returns the value of the Searchable property from the ResultSet's metadata, for the column at the specified index. Returns an empty String in case the property isn't set.- Parameters:
column
- The column index.- Returns:
- The value of the Searchable property of the column.
-
isSigned
public Boolean isSigned(int column)
Returns the value of the Signed property from the ResultSet's metadata, for the column at the specified index. Returns an empty String in case the property isn't set.- Parameters:
column
- The column index.- Returns:
- The value of the Signed property of the column.
-
isWritable
public Boolean isWritable(int column)
Returns the value of the Writable property from the ResultSet's metadata, for the column at the specified index. Returns an empty String in case the property isn't set.- Parameters:
column
- The column index.- Returns:
- The value of the Writable property of the column.
-
getAttribute
public String getAttribute(int column, String name)
Returns the attribute with the given name, for the column at the specified index. Returns an empty String in case the specified attribute name doesn't exist.- Parameters:
column
- The column's indexname
- The attribute's name- Returns:
- The attribute's value, or empty String in case the attribute doesn't exist.
-
getAttribute
public String getAttribute(String columnName, String attributeName)
Returns the attribute with the given name, for the column at the specified index. Returns an empty String in case the specified attribute name doesn't exist.- Parameters:
columnName
- The column's nameattributeName
- The attribute's name- Returns:
- The attribute's value, or empty String in case the attribute doesn't exist.
-
setCatalogName
public void setCatalogName(int column, String catalogName)
Sets the value of the CatalogName property of the ResultSet's metadata to the given value, for the column at the specified index.- Parameters:
column
- The column index.catalogName
- The value of the CatalogName property to set.
-
setColumnClassName
public void setColumnClassName(int column, String className)
Sets the value of the ColumnClassName property of the ResultSet's metadata to the given value, for the column at the specified index.- Parameters:
column
- The column index.className
- The value of the ClassName property to set.
-
setColumnDisplaySize
public void setColumnDisplaySize(int column, int displaySize)
Sets the value of the ColumnDisplaySize property of the ResultSet's metadata to the given value, for the column at the specified index.- Parameters:
column
- The column index.displaySize
- The value of the ColumnDisplaySize property to set.
-
setColumnLabel
public void setColumnLabel(int column, String label)
Sets the value of the ColumnLabel property of the ResultSet's metadata to the given value, for the column at the specified index.- Parameters:
column
- The column index.label
- The value of the ColumnLabel property to set.
-
setColumnName
public void setColumnName(int column, String name)
Sets the value of the ColumnName property of the ResultSet's metadata to the given value, for the column at the specified index.- Parameters:
column
- The column index.name
- The value of the ColumnName property to set.
-
setColumnType
public void setColumnType(int column, int type)
Sets the value of the ColumnType property of the ResultSet's metadata to the given value, for the column at the specified index.- Parameters:
column
- The column index.type
- The value of the ColumnType property to set.
-
setColumnTypeName
public void setColumnTypeName(int column, String typeName)
Sets the value of the ColumnTypeName property of the ResultSet's metadata to the given value, for the column at the specified index.- Parameters:
column
- The column index.typeName
- The value of the ColumnTypeName property to set.
-
setPrecision
public void setPrecision(int column, int precision) throws Exception
Sets the value of the Precision property of the ResultSet's metadata to the given value, for the column at the specified index.- Parameters:
column
- The column index.precision
- The value of the Precision property to set.- Throws:
Exception
-
setScale
public void setScale(int column, int scale) throws Exception
Sets the value of the Scale property of the ResultSet's metadata to the given value, for the column at the specified index.- Parameters:
column
- The column index.scale
- The value of the Scale property to set.- Throws:
Exception
-
setSchemaName
public void setSchemaName(int column, String schemaName)
Sets the value of the SchemaName property of the ResultSet's metadata to the given value, for the column at the specified index.- Parameters:
column
- The column index.schemaName
- The value of the SchemaName property to set.
-
setTableName
public void setTableName(int column, String tableName)
Sets the value of the TableName property of the ResultSet's metadata to the given value, for the column at the specified index.- Parameters:
column
- The column index.tableName
- The value of the TableName property to set.
-
setAutoIncrement
public void setAutoIncrement(int column, Boolean flag)
Sets the value of the AutoIncrement property of the ResultSet's metadata to the given value, for the column at the specified index.- Parameters:
column
- The column index.flag
- The value of the AutoIncrement property to set.
-
setCaseSensitive
public void setCaseSensitive(int column, Boolean flag)
Sets the value of the CaseInsensitive property of the ResultSet's metadata to the given value, for the column at the specified index.- Parameters:
column
- The column index.flag
- The value of the CaseInsensitive property to set.
-
setCurrency
public void setCurrency(int column, Boolean flag)
Sets the value of the Currency property of the ResultSet's metadata to the given value, for the column at the specified index.- Parameters:
column
- The column index.flag
- The value of the Currency property to set.
-
setDefinitelyWritable
public void setDefinitelyWritable(int column, Boolean flag)
Sets the value of the DefinitelyWritable property of the ResultSet's metadata to the given value, for the column at the specified index.- Parameters:
column
- The column index.flag
- The value of the DefinitelyWritable property to set.
-
setNullable
public void setNullable(int column, int nullable) throws Exception
Sets the value of the DefinitelyWritable property of the ResultSet's metadata to the given value, for the column at the specified index.
Note: The Nullable flag can only be one of the following values, else an Exception is thrown.- Parameters:
column
- The column index.- Throws:
Exception
- Gets thrown in case the Nullable flag is not equal any of the above mentioned types.
-
setReadOnly
public void setReadOnly(int column, Boolean flag)
Sets the value of the ReadOnly property of the ResultSet's metadata to the given value, for the column at the specified index.- Parameters:
column
- The column index.flag
- The value of the ReadOnly property to set.
-
setSearchable
public void setSearchable(int column, Boolean flag)
Sets the value of the Searchable property of the ResultSet's metadata to the given value, for the column at the specified index.- Parameters:
column
- The column index.flag
- The value of the Searchable property to set.
-
setSigned
public void setSigned(int column, Boolean flag)
Sets the value of the Signed property of the ResultSet's metadata to the given value, for the column at the specified index.- Parameters:
column
- The column index.flag
- The value of the Signed property to set.
-
setWritable
public void setWritable(int column, Boolean flag)
Sets the value of the Writable property of the ResultSet's metadata to the given value, for the column at the specified index.- Parameters:
column
- The column index.flag
- The value of the Writable property to set.
-
setAttribute
public void setAttribute(int column, String name, String value)
Sets the attribute with the specified name and value to the column at the specified index. Overwrites the value of the attribute with the given one in case an attribute with the given name does already exist.- Parameters:
column
- The column's index.name
- The name of the attribute.value
- The value of the attribute.
-
setAttribute
public void setAttribute(String columnName, String name, String value)
Sets the attribute with the specified name and value to the column at the specified index. Overwrites the value of the attribute with the given one in case an attribute with the given name does already exist.- Parameters:
columnName
- The column's name.name
- The name of the attribute.value
- The value of the attribute.
-
getField
public DataField getField(int column)
Returns the DataField object of the current DataRow for the specified column index. The method converts the column index to the field name and calls theDataRow#getField(String)
method)- Parameters:
column
- The column's index.- Returns:
- the DataField object of the current DataRow for the given column index.
-
isNull
public boolean isNull(int column)
Checks a DataField for null- Parameters:
column
- The column's index.- Returns:
- true if the field is null
-
getString
public String getString(int column)
Retrieves the DataField object of the current DataRow for the specified column index, and returns the DataField's value object as String.- Parameters:
column
- The column's index.- Returns:
- The DataField's value as String.
- See Also:
DataField.getString()
-
getNString
public String getNString(int column)
Retrieves the DataField object of the current DataRow for the specified column index, and returns the DataField's value object as NString.- Parameters:
column
- The column's index.- Returns:
- The DataField's value as String.
- See Also:
DataField.getString()
-
getInt
public Integer getInt(int column)
Retrieves the DataField object of the current DataRow for the specified column index, and returns the DataField's value object as Integer.- Parameters:
column
- The column's index.- Returns:
- The DataField's value as Integer.
- See Also:
DataField.getInt()
-
getByte
public Byte getByte(int column)
Retrieves the DataField object of the current DataRow for the specified column index, and returns the DataField's value object as Byte.- Parameters:
column
- The column's index.- Returns:
- The DataField's value as Byte.
- See Also:
DataField.getByte()
-
getShort
public Short getShort(int column)
Retrieves the DataField object of the current DataRow for the specified column index, and returns the DataField's value object as Short.- Parameters:
column
- The column's index.- Returns:
- The DataField's value as Short.
- See Also:
DataField.getShort()
-
getLong
public Long getLong(int column)
Retrieves the DataField object of the current DataRow for the specified column index, and returns the DataField's value object as Long.- Parameters:
column
- The column's index.- Returns:
- The DataField's value as Long.
- See Also:
DataField.getLong()
-
getBigDecimal
public BigDecimal getBigDecimal(int column)
Retrieves the DataField object of the current DataRow for the specified column index, and returns the DataField's value object as BigDecimal.- Parameters:
column
- The column's index.- Returns:
- The DataField's value as BigDecimal.
- See Also:
DataField.getBigDecimal()
-
getDouble
public Double getDouble(int column)
Retrieves the DataField object of the current DataRow for the specified column index, and returns the DataField's value object as Double.- Parameters:
column
- The column's index.- Returns:
- The DataField's value as Double.
- See Also:
DataField.getDouble()
-
getFloat
public Float getFloat(int column)
Retrieves the DataField object of the current DataRow for the specified column index, and returns the DataField's value object as Float.- Parameters:
column
- The column's index.- Returns:
- The DataField's value as Float.
- See Also:
DataField.getFloat()
-
getBoolean
public Boolean getBoolean(int column)
Retrieves the DataField object of the current DataRow for the specified column index, and returns the DataField's value object as Boolean.- Parameters:
column
- The column's index.- Returns:
- The DataField's value as Boolean.
- See Also:
DataField.getBoolean()
-
getDate
public Date getDate(int column)
Retrieves the DataField object of the current DataRow for the specified column index, and returns the DataField's value object as Date.- Parameters:
column
- The column's index.- Returns:
- The DataField's value as Date.
- See Also:
DataField.getDate()
-
getTime
public Time getTime(int column)
Retrieves the DataField object of the current DataRow for the specified column index, and returns the DataField's value object as Time.- Parameters:
column
- The column's index.- Returns:
- The DataField's value as Time.
- See Also:
DataField.getTime()
-
getTimestamp
public Timestamp getTimestamp(int column)
Retrieves the DataField object of the current DataRow for the specified column index, and returns the DataField's value object as Timestamp.- Parameters:
column
- The column's index.- Returns:
- The DataField's value as Timestamp.
- See Also:
DataField.getTimestamp()
-
getBytes
public byte[] getBytes(int column)
Retrieves the DataField object of the current DataRow for the specified column index, and returns the DataField's value object as Byte array.- Parameters:
column
- The column's index.- Returns:
- The DataField's value as Byte array.
- See Also:
DataField.getBytes()
-
getArray
public Array getArray(int column)
Retrieves the DataField object of the current DataRow for the specified column index, and returns the DataField's value object as Array.- Parameters:
column
- The column's index.- Returns:
- The DataField's value as Array.
- See Also:
DataField.getArray()
-
getBlob
public Blob getBlob(int column)
Retrieves the DataField object of the current DataRow for the specified column index, and returns the DataField's value object as Blob.- Parameters:
column
- The column's index.- Returns:
- The DataField's value as Blob.
- See Also:
DataField.getBlob()
-
getClob
public Clob getClob(int column)
Retrieves the DataField object of the current DataRow for the specified column index, and returns the DataField's value object as Clob.- Parameters:
column
- The column's index.- Returns:
- The DataField's value as Clob.
- See Also:
DataField.getClob()
-
getNClob
public Clob getNClob(int column)
Retrieves the DataField object of the current DataRow for the specified column index, and returns the DataField's value object as NClob.- Parameters:
column
- The column's index.- Returns:
- The DataField's value as NClob.
- See Also:
DataField.getNClob()
-
getObject
public Object getObject(int column)
Retrieves the DataField object of the current DataRow for the specified column index, and returns the DataField's value object.- Parameters:
column
- The column's index.- Returns:
- The DataField's value object.
- See Also:
DataField.getObject()
-
getRef
public Ref getRef(int column)
Retrieves the DataField object of the current DataRow for the specified column index, and returns the DataField's value object as Ref.- Parameters:
column
- The column's index.- Returns:
- The DataField's value as Ref.
- See Also:
DataField.getRef()
-
getURL
public URL getURL(int column)
Retrieves the DataField object of the current DataRow for the specified column index, and returns the DataField's value object as URL.- Parameters:
column
- The column's index.- Returns:
- The DataField's value as URL.
- See Also:
DataField.getURL()
-
setFieldSelection
public void setFieldSelection(List<String> fieldSelection)
Sets the list of field names to be imported into the ResultSet when calling thepopulate(java.sql.ResultSet, Boolean)
method. The populate method will only import the field names from the given list into the ResultSet.- Parameters:
fieldSelection
- The list of column names to import into the ResultSet when calling the populate method.
-
toJson
public String toJson() throws Exception
Returns a JSON String with the ResultSet's content.- Returns:
- The JSON String with the ResultSet's content.
- Throws:
Exception
- Gets thrown in case the JSON String could not be created.
-
toJson
public String toJson(Boolean f_meta) throws Exception
Returns a JSON String with the ResultSet's content.- Returns:
- The JSON String with the ResultSet's content.
- Throws:
Exception
- Gets thrown in case the JSON String could not be created.
-
toJson
public String toJson(Boolean f_meta, String addIndexColumn) throws Exception
Returns a JSON String with the ResultSet's content.- Returns:
- The JSON String with the ResultSet's content.
- Throws:
Exception
- Gets thrown in case the JSON String could not be created.
-
toJson
public String toJson(boolean meta, String addIndexColumn, boolean trimStrings) throws Exception
- Parameters:
meta
- if MetaData should be printedaddIndexColumn
- The Index column which is generated (@Code{null} if it doesn't exist)trimStrings
- if Strings should be trimmed- Returns:
- The Json String containing this ResultSet
- Throws:
Exception
-
toJson
public String toJson(boolean meta, String addIndexColumn, boolean trimStrings, boolean writeDataRowAttributes) throws Exception
- Parameters:
meta
- if MetaData should be printedaddIndexColumn
- The Index column which is generated (@Code{null} if it doesn't exist)trimStrings
- if Strings should be trimmed- Returns:
- The Json String containing this ResultSet
- Throws:
Exception
-
toJRDataSource
public net.sf.jasperreports.engine.JRDataSource toJRDataSource()
Returns this ResultSet as a JRDataSource- Returns:
- JRDataSourceAdapter representing this ResultSet
-
getSQLTypeName
public static String getSQLTypeName(int sqlType)
Returns the name of the given java.sql.Type value, or null in case the given type is unknown.- Parameters:
sqlType
- The SQL Type value.- Returns:
- sqlTypeName The name of the given SQL Type value.
-
fromJson
public static ResultSet fromJson(String js) throws com.fasterxml.jackson.core.JsonParseException, IOException, ParseException
Returns a ResultSet object created by parsing the given JSON String.- Parameters:
js
- The JSON String used to create the ResultSet object.- Returns:
- The ResultSet object created from the values provided in the given JSON String.
- Throws:
ParseException
IOException
com.fasterxml.jackson.core.JsonParseException
- throws an exception if can not parse the json string to a DataRow.
-
getSQLResultSet
public ResultSet getSQLResultSet()
Returns the java.sql.ResultSet object of this com.basiscomponents.db.ResultSet object.- Returns:
- The java.sql.ResultSet object.
-
toJsonElement
public Object toJsonElement()
Returns this ResultSet as com.google.gson.JsonArray object.- Returns:
- This ResultSet as com.google.gson.JsonArray object.
-
count
public int count()
Returns the number of DataRows stored in this ResultSet.- Returns:
- The number of DataRow objects in this ResultSet.
- See Also:
size()
-
sum
public Double sum(String fieldname) throws Exception
Returns the sum of all fields with the specified name, by iterating over all DataRow objects of this ResultSet.- Parameters:
fieldname
- The name of the DataRow field whose value to sum- Returns:
- the sum of all numeric fields with the specified name.
- Throws:
Exception
- Gets thrown in case the specified field value can't be retrieved as number
-
min
public Double min(String fieldname) throws Exception
Returns the min value of all fields with the specified name, by iterating over all DataRow objects of this ResultSet.- Parameters:
fieldname
- The name of the DataRow field.- Returns:
- the min value of all numeric fields with the specified name.
- Throws:
Exception
- Gets thrown in case the specified field value can't be retrieved as number
-
max
public Double max(String fieldname) throws Exception
Returns the max value of all fields with the specified name, by iterating over all DataRow objects of this ResultSet.- Parameters:
fieldname
- The name of the DataRow field.- Returns:
- the max value of all numeric fields with the specified name.
- Throws:
Exception
- Gets thrown in case the specified field value can't be retrieved as number
-
avg
public Double avg(String fieldname) throws Exception
Returns the average value of all fields with the specified name, by iterating over all DataRow objects of this ResultSet.- Parameters:
fieldname
- The name of the DataRow field.- Returns:
- the average value of all numeric fields with the specified name.
- Throws:
Exception
- Gets thrown in case the specified field value can't be retrieved as number
-
median
public Double median(String fieldname) throws Exception
Returns the median value of all fields with the specified name, by iterating over all DataRow objects of this ResultSet.- Parameters:
fieldname
- The name of the DataRow field.- Returns:
- the median value of all numeric fields with the specified name.
- Throws:
Exception
- Gets thrown in case the specified field value can't be retrieved as number
-
countByGroup
public DataRow countByGroup(String fieldname, String labelname) throws Exception
Returns a DataRow which contains all field values of the DataRows defined in this ResultSet for the given field name. The number of field occurrences in all DataRows of this ResultSet will be set as field value in the returned DataRow. In addition, while iterating over the DataRow objects, the method retrieves the field value for the given label name and sets it as attribute of the returned DataRow object.- Parameters:
fieldname
- The name of the field.labelname
- The label name.- Returns:
- A DataRow object with the field values from the DataRows defined in this ResultSet as field names and with the number of occurrences as field values.
- Throws:
Exception
- See Also:
countByGroup(String)
,countByGroup(String, String, int, int)
-
countByGroup
public DataRow countByGroup(String fieldname) throws Exception
Returns a DataRow which contains all field values of the DataRows defined in this ResultSet for the given field name. The number of field occurrences in all DataRows of this ResultSet will be set as field value in the returned DataRow.- Parameters:
fieldname
- The name of the field.- Returns:
- A DataRow object with the field values from the DataRows defined in this ResultSet as field names and with the number of occurrences as field values.
- Throws:
Exception
- See Also:
countByGroup(String, String)
,countByGroup(String, String, int, int)
-
countByGroup
public DataRow countByGroup(String fieldname, String labelname, int sort, int top) throws Exception
Returns a DataRow which contains all field values of the DataRows defined in this ResultSet for the given field name. The number of field occurrences in all DataRows of this ResultSet will be set as field value in the returned DataRow. In addition, while iterating over the DataRow objects, the method retrieves the field value for the given label name and sets it as attribute of the returned DataRow object.
The sort parameter can be used to sort the created DataRow's fields. The sort parameter can only have predefined values, see below. The top parameter is used to limit the field names of the returned DataRow to the given value.
The only allowed values for the sorting are:- ResultSet.NO_SORT (default)
- ResultSet.SORT_ON_GROUPFIELD
- ResultSet.SORT_ON_GROUPLABEL
- ResultSet.SORT_ON_RESULT
- ResultSet.SORT_ON_GROUPFIELD_DESC
- ResultSet.SORT_ON_GROUPLABEL_DESC
- ResultSet.SORT_ON_RESULT_DESC
- Parameters:
fieldname
- The name of the field.labelname
- The label name.sort
- The sorting code.top
- The maximal number of field's of the new DataRow object.- Returns:
- A DataRow object with the field values from the DataRows defined in this ResultSet as field names and with the number of occurrences as field values.
- Throws:
Exception
- See Also:
countByGroup(String)
,countByGroup(String, String)
-
sumByGroup
public DataRow sumByGroup(String fieldname, String sumfieldname) throws Exception
Returns a DataRow which contains all field values of the DataRows defined in this ResultSet for the given field name. Sums the value of the field with the given field name(sumfieldname) and sets it as field value to the DataRow. In addition, while iterating over the DataRow objects, the method retrieves the field value for the given label name and sets it as attribute of the returned DataRow object.- Parameters:
fieldname
- The name of the field.sumfieldname
- The field name whose value should be summed- Returns:
- A DataRow object with the field values from the DataRows defined in this ResultSet as field names and with the sum of the values of the field with the given name as field values.
- Throws:
Exception
- See Also:
sumByGroup(String, String, String, int, int)
-
sumByGroup
public DataRow sumByGroup(String fieldname, String labelname, String sumfieldname, int sort, int top) throws Exception
Returns a DataRow which contains all field values of the DataRows defined in this ResultSet for the given field name. Sums the value of the field with the given field name(sumfieldname) and sets it as field value to the DataRow. In addition, while iterating over the DataRow objects, the method retrieves the field value for the given label name and sets it as attribute of the returned DataRow object.
The sort parameter can be used to sort the created DataRow's fields. The sort parameter can only have predefined values, see below. The top parameter is used to limit the field names of the returned DataRow to the given value.
The only allowed values for the sorting are:- ResultSet.NO_SORT (default)
- ResultSet.SORT_ON_GROUPFIELD
- ResultSet.SORT_ON_GROUPLABEL
- ResultSet.SORT_ON_RESULT
- ResultSet.SORT_ON_GROUPFIELD_DESC
- ResultSet.SORT_ON_GROUPLABEL_DESC
- ResultSet.SORT_ON_RESULT_DESC
- Parameters:
fieldname
- The name of the field.labelname
- The label name.sumfieldname
- The field name whose value should be summedsort
- The sort code.top
- The maximal number of field's of the new DataRow object.- Returns:
- A DataRow object with the field values from the DataRows defined in this ResultSet as field names and with the sum of the values of the field with the given name as field values.
- Throws:
Exception
- See Also:
sumByGroup(String, String)
-
buildRowKey
public void buildRowKey(ResultSet rs, DataRow dr) throws NoSuchFieldException, SQLException
- Throws:
NoSuchFieldException
SQLException
-
getBBTemplate
public String getBBTemplate()
Creates and returns simplified BB template definition based on result set metadata, analog SQLTMPL().- Returns:
- String Template definition
-
getBBTemplate
public String getBBTemplate(Boolean extendedInfo)
Creates and returns BB template definition based on ResultSetMeatData, analog SQLTMPL().- Parameters:
extendedInfo
- Adds more information to template if true- Returns:
- String Template definition
-
isIndexed
public Boolean isIndexed()
isIndexed: check if the ResultSet has an internal index row that would allow access by a key instead of the numeric integer index- Returns:
-
createIndex
public void createIndex() throws ParseException
- Throws:
ParseException
-
reCreateIndex
public void reCreateIndex() throws ParseException
- Throws:
ParseException
-
print
public void print()
-
merge
public void merge(ResultSet rs2, String onFieldName, boolean fOverwrite)
- Parameters:
rs2
- : the resultset to merge inonFieldName
- : the field name to use to identify matchesfOverwrite
- : set to true if you want to overwrite fields that exist in both
-
setConversionRuleSet
public void setConversionRuleSet(ConversionRuleSet crs)
Sets a global conversion rule set which is honored for standard output methods, like print and toJson. Note: For setting and getting data directly with DataRow objects, you will still need to pass the rule set with the setField... and getField methods.- Parameters:
crs
-
-
clearConversionRuleSet
public void clearConversionRuleSet()
Clears a global conversion rule set
-
getConversionRuleSet
public ConversionRuleSet getConversionRuleSet()
- Returns:
- The current ConversionRuleSet or null, if none is set
-
-