|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.josql.Query org.josql.contrib.JoSQLSwingTableModel
public class JoSQLSwingTableModel
A table model suitable for use with Swing JTable.
This is basically just an extension to Query
that allows the
results to be iterated over, thereby providing the ability for objects to be reported on
that are held in memory.
One limitation here is that the SQL query must return columns rather than the objects since the values need to be mapped by the renderer and editor. For example:
SELECT lastModified, name FROM java.io.File WHERE name LIKE '%.html'
This query would work but it should be noted that the select "columns" (since they do not have aliases assigned) will be labeled 1, 2, X and so on. You can assign aliases to the "columns" and then use them in the report definition file.
Field Summary |
---|
Fields inherited from class org.josql.Query |
---|
ALL, ALL_OBJS_VAR_NAME, CURR_OBJ_VAR_NAME, GROUP_BY_RESULTS, GRPBY_OBJ_VAR_NAME, GRPBY_OBJ_VAR_NAME_SYNONYM, HAVING_RESULTS, INT_BIND_VAR_PREFIX, nullQueryList, ORDER_BY_ASC, ORDER_BY_DESC, PARENT_BIND_VAR_NAME, QUERY_BIND_VAR_NAME, RESULTS, WHERE_RESULTS |
Constructor Summary | |
---|---|
JoSQLSwingTableModel()
|
Method Summary | |
---|---|
void |
addTableModelListener(TableModelListener l)
|
void |
clearResults()
Clear any results. |
QueryResults |
execute(List l)
Exectute the query and return the results. |
Class |
getColumnClass(int i)
The expected class of the object at column i. |
int |
getColumnCount()
Get the number of columns. |
String |
getColumnName(int ind)
Get the name of the column, if the query has not yet been parsed then null is returned,
if the column does not have an alias then "ind + 1" is returned. |
QueryResults |
getResults()
Get any results, will be null unless execute(List) has been called. |
int |
getRowCount()
Number of rows. |
Object |
getValueAt(int r,
int c)
Get the object at row r, column c. |
boolean |
isCellEditable(int r,
int c)
Cells are not editable since we do not store the results separately. |
void |
parse(String sql)
Parse the SQL. |
void |
removeTableModelListener(TableModelListener l)
|
QueryResults |
reorder(List objs,
SortedMap dirs)
Re-order the columns according to the column indices provided in dirs. |
QueryResults |
reorder(List objs,
String orderBys)
Re-order the columns according to the string representation provided by orderBys. |
void |
setValueAt(Object v,
int r,
int c)
Not supported, always throws a: UnsupportedOperationException . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public JoSQLSwingTableModel()
Method Detail |
---|
public void parse(String sql) throws QueryParseException
parse
in class Query
sql
- The SQL.
QueryParseException
- If the sql cannot be parsed or if the query will not return
columns.public QueryResults reorder(List objs, SortedMap dirs) throws QueryExecutionException, QueryParseException
reorder
in class Query
objs
- The objects to reorder.dirs
- The columns to order by.
QueryExecutionException
- If something goes wrong during execution of the
query.
QueryParseException
- If the column indices are out of range for the statement.Query.reorder(List,SortedMap)
public QueryResults reorder(List objs, String orderBys) throws QueryParseException, QueryExecutionException
reorder
in class Query
objs
- The objects to reorder.orderBys
- The columns to order by.
QueryExecutionException
- If something goes wrong during execution of the
query.
QueryParseException
- If the column indices are out of range for the statement.Query.reorder(List,String)
public QueryResults execute(List l) throws QueryExecutionException
execute
in class Query
l
- The List of objects to execute the query on.
QueryExecutionException
- If the query cannot be executed, or if the query
is set to return objects rather than "columns".public QueryResults getResults()
execute(List)
has been called.
public void clearResults()
public String getColumnName(int ind)
null
is returned,
if the column does not have an alias then "ind + 1" is returned.
getColumnName
in interface TableModel
public Class getColumnClass(int i)
getColumnClass
in interface TableModel
public Object getValueAt(int r, int c)
getValueAt
in interface TableModel
r
- The row.c
- The column.
public void setValueAt(Object v, int r, int c) throws UnsupportedOperationException
UnsupportedOperationException
.
setValueAt
in interface TableModel
v
- The object to set at the location.r
- The row.c
- The column.
UnsupportedOperationException
- Not supported.public boolean isCellEditable(int r, int c)
isCellEditable
in interface TableModel
r
- The row.c
- The columns.
false
.public int getRowCount()
getRowCount
in interface TableModel
public int getColumnCount()
getColumnCount
in interface TableModel
public void removeTableModelListener(TableModelListener l)
removeTableModelListener
in interface TableModel
public void addTableModelListener(TableModelListener l)
addTableModelListener
in interface TableModel
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |