|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface TableStorage
Load tables from a database through this generic interface. You can use tables loaded through here for a GUI (JTable, e.g. TablePanel
), or for simply accessing the database from code.
Between this generic interface and DataTableModel
, you can access any generic database and do most operations without writing any SQL, thus keeping your implementation non-specific to any particular SQL language or database.
The extra layer adds some functionality, and makes databases more swappable if you need to.
By using TableFormat to load a table, you can have the table automatically created if needed, and upgraded if you make a newer version of it. Also, for a bit of help, see TableStorageStub
.
For anyone trying to implement this class:
Unmentioned it this interface is that you're required to use TableVersionStorage when creating a new table and upgrading an old table.
DataTableModel
Nested Class Summary | |
---|---|
static interface |
TableStorage.SearchingForConnectionListener
Recieves notifications of whether the TableStorage is currently unavailable and waiting for a new connection. |
static interface |
TableStorage.TableListListener
Recieves notifications whenever the list of tables changes -- i.e. on any of these events: - a table is created - a table is deleted - a table is renamed |
Method Summary | |
---|---|
void |
addSearchingForConnectionListener(TableStorage.SearchingForConnectionListener listener)
Add a listener to find when TableStorage is unavailable (usually due to network issues). |
void |
addTableListListener(TableStorage.TableListListener listener)
|
void |
cancelSearchingForConnection()
Stop waiting for the TableStorage to be connected -- and start throwing exceptions. |
void |
close()
Call this when you're done with this class and will not use it again. |
boolean |
deleteTable(java.lang.String tableName)
|
java.lang.String |
getLastErrorMessage()
Returns an error message, if there was one, from the most recent error. |
DataTableModel |
getTable(java.lang.String tableName)
Get the table so named. |
DataTableModel |
getTable(TableFormat tableFormat)
Gets the table with that format. |
java.util.Vector<java.lang.String> |
getTableNames()
|
boolean |
isOpen()
|
boolean |
isTableNamesCaseSensitive()
True if table names are case sensitive, false if table names are not case sensitive. |
boolean |
isValidLabelString(java.lang.String labelString)
Returns whether or not a string is a valid name for tables, columns, etc. |
DataTableModel |
newTable(java.lang.String tableName,
java.util.List<java.lang.String> columnNames,
java.util.List<java.lang.Class> columnTypes)
|
DataTableModel |
newTable(java.lang.String tableName,
java.util.List<java.lang.String> columnNames,
java.util.List<java.lang.Class> columnTypes,
java.lang.Integer primaryKeyColumn)
|
DataTableModel |
newTable(java.lang.String tableName,
java.util.List<java.lang.String> columnNames,
java.util.List<java.lang.Class> columnTypes,
java.util.List<java.lang.Boolean> columnAllowsNull,
java.util.List<java.lang.Object> columnDefaultValues,
java.lang.Integer primaryKeyColumn)
Creates a new table in the database, and returns it, or null if it fails. |
DataTableModel |
newTable(java.lang.String tableName,
java.lang.String[] columnNames,
java.lang.Class[] columnTypes)
|
DataTableModel |
newTable(java.lang.String tableName,
java.lang.String[] columnNames,
java.lang.Class[] columnTypes,
java.lang.Integer primaryKeyColumn)
|
DataTableModel |
newTable(TableFormat tableFormat)
|
void |
removeSearchingForConnectionListener(TableStorage.SearchingForConnectionListener listener)
Removes a listener to find when TableStorage is unavailable (usually due to network issues). |
void |
removeTableListListener(TableStorage.TableListListener listener)
|
boolean |
renameTable(java.lang.String oldTableName,
java.lang.String newTableName)
|
boolean |
tableExists(java.lang.String tableName)
|
Method Detail |
---|
boolean tableExists(java.lang.String tableName)
DataTableModel newTable(TableFormat tableFormat)
newTable(String, List, List, List, List, int);
DataTableModel newTable(java.lang.String tableName, java.util.List<java.lang.String> columnNames, java.util.List<java.lang.Class> columnTypes)
newTable(String, List, List, List, List, int);
DataTableModel newTable(java.lang.String tableName, java.lang.String[] columnNames, java.lang.Class[] columnTypes)
newTable(String, List, List, List, List, int);
DataTableModel newTable(java.lang.String tableName, java.lang.String[] columnNames, java.lang.Class[] columnTypes, java.lang.Integer primaryKeyColumn)
newTable(String, List, List, List, List, int);
DataTableModel newTable(java.lang.String tableName, java.util.List<java.lang.String> columnNames, java.util.List<java.lang.Class> columnTypes, java.lang.Integer primaryKeyColumn)
newTable(String, List, List, List, List, int);
DataTableModel newTable(java.lang.String tableName, java.util.List<java.lang.String> columnNames, java.util.List<java.lang.Class> columnTypes, java.util.List<java.lang.Boolean> columnAllowsNull, java.util.List<java.lang.Object> columnDefaultValues, java.lang.Integer primaryKeyColumn)
tableName
- columnNames
- A Vector of String of the names of each columncolumnTypes
- A Vector of Class with the types of each column -- must be the
same size() as columnNames.columnAllowsNull
- (optional)
A Vector of Boolean as to whether or not the column allows null as a value.columnDefaultValues
- (optional)
A Vector of Object, for the default value in each column when it's there.primaryKeyColumn
- (optional, -1 if none)
An index into columnNames with the primary key column. If
there is no primary key, it should be -1. If the primary key
column is an Integer, it will also be made as an auto-incrementing
column.
java.util.Vector<java.lang.String> getTableNames()
boolean isTableNamesCaseSensitive()
DataTableModel getTable(java.lang.String tableName)
tableName
-
DataTableModel getTable(TableFormat tableFormat)
tableFormat
- format the table should be in
boolean deleteTable(java.lang.String tableName)
boolean renameTable(java.lang.String oldTableName, java.lang.String newTableName)
boolean isValidLabelString(java.lang.String labelString)
labelString
-
void cancelSearchingForConnection()
void addSearchingForConnectionListener(TableStorage.SearchingForConnectionListener listener)
void removeSearchingForConnectionListener(TableStorage.SearchingForConnectionListener listener)
listener
- void addTableListListener(TableStorage.TableListListener listener)
void removeTableListListener(TableStorage.TableListListener listener)
java.lang.String getLastErrorMessage()
boolean isOpen()
void close()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |