D
- Class of the subclass (an implementation of AbstractDbData
) : useful for the fluent methods
(setters).public abstract class AbstractDbData<D extends AbstractDbData<D>> extends AbstractDbElement<D>
Table
or a Request
).
That could be data from a Table
or from a Request
.
So this class contains the list of columns name (getColumnsNameList()
),
the list of primary keys name (getPksNameList()
)
and the list of the rows (getRowsList()
).
The first call to one of these methods triggers a loading from the database.
myself
Modifier and Type | Method and Description |
---|---|
protected void |
collectRowsFromResultSet(ResultSet resultSet)
Collects rows from a
ResultSet . |
protected void |
controlIfAllThePksNameExistInTheColumns()
Controls that all the primary keys name exist in the columns.
|
Column |
getColumn(int index)
Returns the column corresponding to the column index in parameter and the values inside the column.
|
List<Column> |
getColumnsList()
Returns the list of the values in columns for the data from database.
|
List<String> |
getColumnsNameList()
Return the list of the columns name for the data from database.
|
DataType |
getDataType()
Returns the type of the data on which is the change.
|
List<String> |
getPksNameList()
Return the list of the primary key name for the data from database.
|
abstract String |
getRequest()
Returns the SQL request.
|
Row |
getRow(int index)
Returns the row corresponding to the index.
|
Row |
getRowFromPksValues(Value... pksValues)
Returns the
Row with the primary keys values in parameter. |
List<Row> |
getRowsList()
Returns the list of the values in rows for the data from database.
|
protected abstract void |
loadImpl(Connection connection)
Implementation of the loading that depends of the kind of data.
|
protected void |
setColumnsNameList(List<String> columnsNameList)
Sets the list of the columns name.
|
protected void |
setPksNameList(List<String> pksNameList)
Sets the list of the primary key name.
|
protected void |
sortRows()
Sorts the list of rows.
|
getCatalog, getColumnLetterCase, getConnection, getDataSource, getPrimaryKeyLetterCase, getSchema, getSource, getTableLetterCase, setDataSource, setSource
public DataType getDataType()
public abstract String getRequest()
Table.getRequest()
,
Request.getRequest()
protected void sortRows()
protected abstract void loadImpl(Connection connection) throws SQLException
In fact it is like in the Skeleton Design Pattern : this method is called by the load()
method but loadImpl()
is abstract here and it is implemented in the sub-classes depending of the need of
the sub-class.
connection
- Connection
to the database provided by load()
method.SQLException
- SQL Exception.Table.loadImpl(Connection)
,
Request.loadImpl(Connection)
protected void collectRowsFromResultSet(ResultSet resultSet) throws SQLException
ResultSet
.
This method browse the ResultSet
in parameter to get the data and fill the list of Row
(
rowsList
) with these data.
resultSet
- The ResultSet
.SQLException
- A SQL Exception.public List<String> getColumnsNameList()
If it is the first call to getColumnsNameList()
, the data are loaded from database by calling the
load()
private method.
NullPointerException
- If the AbstractDbElement.dataSource
and AbstractDbElement.source
fields are null
.AssertJDBException
- If triggered, this exception wrap a possible SQLException
during the loading.protected void setColumnsNameList(List<String> columnsNameList)
columnsNameList
- The list of the columns name.public List<String> getPksNameList()
If it is the first call to getIdsNameList()
, the data are loaded from database by calling the
load()
private method.
NullPointerException
- If the AbstractDbElement.dataSource
and AbstractDbElement.source
fields are null
.AssertJDBException
- If triggered, this exception wrap a possible SQLException
during the loading.protected void controlIfAllThePksNameExistInTheColumns()
protected void setPksNameList(List<String> pksNameList)
pksNameList
- The list of the primary keys name.AssertJDBException
- If one the primary keys do not exist in the columns name, the exception is triggered.public List<Row> getRowsList()
If it is the first call to getRowsList()
, the data are loaded from database by calling the load()
private method.
NullPointerException
- If the AbstractDbElement.dataSource
and AbstractDbElement.source
fields are null
.AssertJDBException
- If triggered, this exception wrap a possible SQLException
during the loading.public List<Column> getColumnsList()
This method calls getColumnsNameList()
and getValuesList(int)
which calls getRowsList()
.
If it is the first call to getColumnsNameList()
or getRowsList()
, the data are loaded from
database by calling the load()
private method.
NullPointerException
- If the AbstractDbElement.dataSource
and AbstractDbElement.source
fields are null
.AssertJDBException
- If triggered, this exception wrap a possible SQLException
during the loading.public Column getColumn(int index)
This method calls getColumnsNameList()
and getValuesList(int)
which calls getRowsList()
.
If it is the first call to getColumnsNameList()
or getRowsList()
, the data are loaded from
database by calling the load()
private method.
index
- The column index.NullPointerException
- If the AbstractDbElement.dataSource
and AbstractDbElement.source
fields are null
.AssertJDBException
- If triggered, this exception wrap a possible SQLException
during the loading.public Row getRow(int index)
This method calls getRowsList()
.
If it is the first call to getRowsList()
, the data are loaded from database by calling the load()
private method.
index
- The indexRow
NullPointerException
- If the AbstractDbElement.dataSource
and AbstractDbElement.source
fields are null
.AssertJDBException
- If triggered, this exception wrap a possible SQLException
during the loading.Copyright © 2020 AssertJ. All rights reserved.