|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.swing.table.AbstractTableModel cmu.survey.data.DataTableModel cmu.survey.data.sql.DataTableModelSQL cmu.survey.data.mysql.DataTableModelMySQL
public class DataTableModelMySQL
Nested Class Summary | |
---|---|
class |
DataTableModelMySQL.ForwardOnlyDataSQL
|
Nested classes/interfaces inherited from class cmu.survey.data.DataTableModel |
---|
DataTableModel.DataTableModelGUIListener, DataTableModel.Results |
Field Summary | |
---|---|
protected static boolean |
debug
|
Fields inherited from class cmu.survey.data.sql.DataTableModelSQL |
---|
CheckWhetherColumnNamesAreValid, filters, orderBys, resultSet, sqlOrderBy, sqlWhere |
Fields inherited from class cmu.survey.data.DataTableModel |
---|
COLUMN_TYPES, COLUMN_TYPES_READABLE, holdFiredTableChangeEvents, INTEGER_TYPE_READABLE, levelOfEventsHeld, thisDataTableModel |
Fields inherited from class javax.swing.table.AbstractTableModel |
---|
listenerList |
Constructor Summary | |
---|---|
DataTableModelMySQL(TableStorageMySQL objectStorage,
DataTableModelSingularInfo tableInfo)
|
Method Summary | |
---|---|
protected void |
cacheColumnNames(java.sql.ResultSet resultSet)
|
boolean |
changeColumnClass(java.lang.String columnName,
java.lang.Class newColumnClass,
boolean allowsNull,
java.lang.String defaultValue)
|
void |
close()
|
protected void |
deleteColumnNoRefresh(java.lang.String columnName)
|
boolean |
deleteDataBits(java.lang.String uniqueIDColumnName,
java.lang.Integer uniqueID)
|
protected boolean |
deleteRowProtected(int row)
Implement this to delete a row. |
boolean |
equals(java.lang.Object o)
|
protected void |
filtersWereChanged()
Called after the Filters are changed. |
java.lang.Class<?> |
getColumnClass(int c)
|
int |
getColumnCount()
|
java.lang.String[] |
getColumnNames()
|
static java.lang.String |
getColumnTypeAsSQLString(java.lang.Class columnType)
|
java.lang.Integer |
getCount(java.lang.String columnName,
java.lang.String filterEquals,
java.lang.Object value)
|
protected DatabaseQuery |
getDatabaseQuery()
Gets the query, also refreshes it if needed. |
Filter<?> |
getFilterForColumn(java.lang.String columnName,
java.lang.String filterEquals,
java.lang.Object value)
|
protected java.lang.String |
getFilterWhereAsSQLWhere()
|
ForwardOnlyData |
getForwardOnlyData()
|
java.lang.String |
getInvalidColumnNameMessage(java.lang.String columnName)
If this column name is not allowed, returns a brief message saying what's invalid about the name. |
java.lang.Object |
getMax(java.lang.String columnName)
Get the maximum value of a column. |
java.lang.Integer |
getPrimaryKey()
|
int |
getRowCount()
|
TableStorage |
getTableStorage()
|
java.lang.Object |
getValueAt(int row,
int col)
|
java.lang.Object |
getValueAtGetErrors(int row,
int col)
|
boolean |
isCellEditable(int row,
int col)
|
boolean |
isColumnNullable(int col)
|
boolean |
isEditable()
|
boolean |
isFilterValid()
|
boolean |
isOrderByValid()
Should be used when a query with an orderby fails, to check if the order by was okay and give a better error message. |
boolean |
isValidColumnName(java.lang.String columnName)
Check whether a column name is allowed or not. |
static void |
main(java.lang.String[] args)
|
boolean |
newColumn(java.lang.String columnName,
java.lang.Class type,
java.lang.String afterColumnName,
boolean createAsFirstColumn,
boolean isPrimaryKey,
boolean allowsNull,
java.lang.Object defaultValue)
|
boolean |
newRow()
|
boolean |
newRow(java.util.List<? extends java.lang.Object> rowValues)
|
boolean |
newRow(java.util.List<java.lang.String> columnNames,
java.util.List<? extends java.lang.Object> rowValues)
|
DataTableModel.Results |
newRows(java.util.List<? extends java.util.List<? extends java.lang.Object>> rowOfRows)
See Results class for description of what the boolean's mean. |
DataTableModel.Results |
newRows(java.util.List<java.lang.String> columnNames,
java.util.List<? extends java.util.List<? extends java.lang.Object>> rowOfRows)
|
protected void |
orderBysWereChanged()
Does not check whether the order bys are valid. |
void |
refresh()
Refreshes its data -- reloads any data from any info from the database that it can reload, and should call fireTableStructureChanged() or another appropriate fire to update GUIs. |
protected void |
refreshTableSQL()
|
boolean |
renameColumn(java.lang.String oldColumnName,
java.lang.String newColumnName)
|
boolean |
reorderColumn(java.lang.String columnName,
int newIndex)
|
void |
resetPrimaryKeyColumnIndex()
If the primary key is an integer column, and an auto-incrementing column, it resets the column's next new integer to the lowest possible (if the table is empty, starts at 1) -- if it is not an integer and not an auto-incrementing column, it will NOT reset the column's index. |
java.lang.Integer |
saveDataBits(java.util.List<? extends DataBit> dataBits,
java.lang.String uniqueIDColumnName,
java.lang.Integer uniqueID,
boolean isNew)
Takes a set of data bits. |
boolean |
saveDataBits(java.util.List<? extends DataBit> dataBits,
java.lang.String uniqueIDColumnName,
java.lang.String uniqueID,
boolean isNew)
Save |
java.lang.Object |
saveDataBitsPrivate(java.util.List<? extends DataBit<?>> dataBits,
java.lang.String uniqueIDColumnName,
java.lang.Object uniqueID,
boolean isNew)
|
protected boolean |
setValueAtProtected(java.lang.Object value,
int row,
int col)
Implement this to set values. |
protected void |
setValueAtProtected(java.sql.ResultSet resultSet,
int columnIndex,
java.lang.Object value)
prerequisites: resultSet should be on the right row. |
protected void |
sqlOrderByWasChanged()
|
protected void |
sqlTableNameWasChanged()
Called after the sql table name was changed. |
protected void |
sqlWhereWasChanged()
|
void |
tableWasRenamedTo(java.lang.String oldTableName,
java.lang.String newTableName)
Notification that a used table name was renamed (and that you should refresh queries, names, etc). |
java.lang.String |
toString()
|
Methods inherited from class cmu.survey.data.sql.DataTableModelSQL |
---|
addFilter, addOrderBy, deleteAllRows, deleteColumn, deleteColumns, filterChanged, getFilters, getOrderBys, getSQLOrderBy, getSQLWhere, removeAllFilters, removeAllOrderBys, removeColumnFromPlaces, removeFilter, removeOrderBy, setFilters, setSQLOrderBy, setSQLWhere |
Methods inherited from class javax.swing.table.AbstractTableModel |
---|
findColumn, fireTableChanged, getListeners, getTableModelListeners |
Methods inherited from class java.lang.Object |
---|
clone, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static final boolean debug
Constructor Detail |
---|
public DataTableModelMySQL(TableStorageMySQL objectStorage, DataTableModelSingularInfo tableInfo)
Method Detail |
---|
protected void refreshTableSQL()
protected void filtersWereChanged()
DataTableModelSQL
filtersWereChanged
in class DataTableModelSQL
protected java.lang.String getFilterWhereAsSQLWhere()
getFilterWhereAsSQLWhere
in class DataTableModelSQL
public boolean isFilterValid()
protected void orderBysWereChanged()
orderBysWereChanged
in class DataTableModelSQL
protected void sqlTableNameWasChanged()
DataTableModelSQL
sqlTableNameWasChanged
in class DataTableModelSQL
protected void sqlWhereWasChanged()
sqlWhereWasChanged
in class DataTableModelSQL
protected void sqlOrderByWasChanged()
sqlOrderByWasChanged
in class DataTableModelSQL
public boolean isOrderByValid()
public static java.lang.String getColumnTypeAsSQLString(java.lang.Class columnType)
protected DatabaseQuery getDatabaseQuery()
getDatabaseQuery
in class DataTableModelSQL
public void refresh()
DataTableModel
refresh
in class DataTableModel
public int getColumnCount()
public int getRowCount()
public java.lang.Object getValueAtGetErrors(int row, int col) throws FailedRequest
FailedRequest
public java.lang.Object getValueAt(int row, int col)
protected void setValueAtProtected(java.sql.ResultSet resultSet, int columnIndex, java.lang.Object value) throws FailedRequest
resultSet
- -- is assumed to already be on the right row.columnName
- this OR columnName is requiredcolumnIndex
- this OR columnName is requiredvalue
-
FailedRequest
protected boolean setValueAtProtected(java.lang.Object value, int row, int col)
DataTableModel
setValueAtProtected
in class DataTableModel
public java.lang.String[] getColumnNames()
getColumnNames
in class DataTableModel
protected void cacheColumnNames(java.sql.ResultSet resultSet)
public java.lang.Class<?> getColumnClass(int c)
getColumnClass
in interface javax.swing.table.TableModel
getColumnClass
in class javax.swing.table.AbstractTableModel
public java.lang.Integer getPrimaryKey()
getPrimaryKey
in class DataTableModel
public boolean isEditable()
isEditable
in class DataTableModel
public boolean isCellEditable(int row, int col)
isCellEditable
in interface javax.swing.table.TableModel
isCellEditable
in class javax.swing.table.AbstractTableModel
public boolean isColumnNullable(int col)
isColumnNullable
in class DataTableModel
protected boolean deleteRowProtected(int row)
DataTableModel
deleteRowProtected
in class DataTableModel
rows
- -- MUST be in order from lowest rowID to highest rowID, but does not need to be consecutive.
public boolean newRow()
newRow
in class DataTableModel
public boolean newRow(java.util.List<? extends java.lang.Object> rowValues)
newRow
in class DataTableModel
rowValues
- The values, in order by the column order. Each value must be of the correct class for the type of the column (i.e. An int must be class Integer).public DataTableModel.Results newRows(java.util.List<? extends java.util.List<? extends java.lang.Object>> rowOfRows)
DataTableModel
newRows
in class DataTableModel
public DataTableModel.Results newRows(java.util.List<java.lang.String> columnNames, java.util.List<? extends java.util.List<? extends java.lang.Object>> rowOfRows)
public boolean newRow(java.util.List<java.lang.String> columnNames, java.util.List<? extends java.lang.Object> rowValues)
newRow
in class DataTableModel
columnNames
- The names of the columns that values should be inserted into.rowValues
- The values for this row for each column. Each value must be of the correct class for the type of the column (i.e. An int must be class Integer).
public TableStorage getTableStorage()
getTableStorage
in class DataTableModel
public boolean changeColumnClass(java.lang.String columnName, java.lang.Class newColumnClass, boolean allowsNull, java.lang.String defaultValue)
changeColumnClass
in class DataTableModel
public boolean isValidColumnName(java.lang.String columnName)
DataTableModel
isValidColumnName
in class DataTableModel
public java.lang.String getInvalidColumnNameMessage(java.lang.String columnName)
DataTableModel
getInvalidColumnNameMessage
in class DataTableModel
public boolean renameColumn(java.lang.String oldColumnName, java.lang.String newColumnName)
renameColumn
in class DataTableModel
public boolean reorderColumn(java.lang.String columnName, int newIndex)
reorderColumn
in class DataTableModel
public boolean newColumn(java.lang.String columnName, java.lang.Class type, java.lang.String afterColumnName, boolean createAsFirstColumn, boolean isPrimaryKey, boolean allowsNull, java.lang.Object defaultValue)
newColumn
in class DataTableModel
protected void deleteColumnNoRefresh(java.lang.String columnName) throws FailedRequest
deleteColumnNoRefresh
in class DataTableModelSQL
FailedRequest
public void tableWasRenamedTo(java.lang.String oldTableName, java.lang.String newTableName)
tableWasRenamedTo
in class DataTableModel
public java.lang.Integer saveDataBits(java.util.List<? extends DataBit> dataBits, java.lang.String uniqueIDColumnName, java.lang.Integer uniqueID, boolean isNew)
DataTableModel
saveDataBits
in class DataTableModel
isNew
- whether or not this is a new record that has not been previously saved -- whether or not the row exists already.
public boolean saveDataBits(java.util.List<? extends DataBit> dataBits, java.lang.String uniqueIDColumnName, java.lang.String uniqueID, boolean isNew)
DataTableModel
saveDataBits
in class DataTableModel
uniqueID
- The unique ID to save as -- cannot be null, since it can't be automatically assigned.
public java.lang.Object saveDataBitsPrivate(java.util.List<? extends DataBit<?>> dataBits, java.lang.String uniqueIDColumnName, java.lang.Object uniqueID, boolean isNew)
public boolean deleteDataBits(java.lang.String uniqueIDColumnName, java.lang.Integer uniqueID)
deleteDataBits
in class DataTableModel
public ForwardOnlyData getForwardOnlyData()
getForwardOnlyData
in class DataTableModel
public Filter<?> getFilterForColumn(java.lang.String columnName, java.lang.String filterEquals, java.lang.Object value) throws FailedRequest
FailedRequest
public java.lang.Object getMax(java.lang.String columnName) throws FailedRequest
DataTableModel
getMax
in class DataTableModel
FailedRequest
public java.lang.Integer getCount(java.lang.String columnName, java.lang.String filterEquals, java.lang.Object value) throws FailedRequest
getCount
in class DataTableModel
FailedRequest
public void resetPrimaryKeyColumnIndex() throws FailedRequest
DataTableModel
resetPrimaryKeyColumnIndex
in class DataTableModel
FailedRequest
public void close()
close
in class DataTableModel
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public static final void main(java.lang.String[] args) throws java.lang.Throwable
java.lang.Throwable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |