com.antelmann.util.table
Class PatternTableModel<T>
java.lang.Object
javax.swing.table.AbstractTableModel
com.antelmann.util.table.AbstractObjectTableModel<T>
com.antelmann.util.table.PatternTableModel<T>
- All Implemented Interfaces:
- ListRetriever<T>, Refreshable, ObjectTableModel<T>, Serializable, Iterable<T>, TableModel
- Direct Known Subclasses:
- MessageTableModel
public class PatternTableModel<T>
- extends AbstractObjectTableModel<T>
a very flexible ObjectTableModel that allows to define PatternExtractors per column
- Since:
- 03.01.2012, 15:10:32
- Author:
- Holger Antelmann
- See Also:
PatternExtractor,
Misc.getMethodExtractor(String, Class),
PropertyEntryImpl.getPropertyExtractor(String, Class),
Serialized Form
|
Method Summary |
void |
addColumn(Class<T> entryType,
String columnName,
String methodOrFieldName,
boolean ensureAccessibility)
convenience method |
|
addColumn(String name,
Field field)
|
|
addColumn(String name,
Method method)
|
void |
addColumn(String name,
PatternExtractor<? super T,?> pe)
|
|
addColumn(String name,
PatternExtractor<? super T,P> pe,
Class<? super P> type)
this method is called by all other addColumn.. methods and provides most flexibility
as well as best performance depending on the efficient implementation of a given
PatternExtractor. |
void |
addColumn(String columnName,
String methodName)
|
|
addColumn(String columnName,
String methodName,
Class<R> returnType)
allows to easily add a column based on the method name. |
static Field |
findField(Class<?> type,
String fieldName)
looks for the field in the declared class and its super classes |
static Method |
findMethod(Class<?> type,
String methodName)
looks for the method with no arguments in the declared class and its super classes |
Class<?> |
getColumnClass(int column)
|
int |
getColumnCount()
|
String |
getColumnName(int column)
|
Object |
getValueAt(int row,
int column)
|
boolean |
isCellEditable(int row,
int column)
|
void |
removeColumn(int c)
|
void |
removeColumn(String c)
|
String |
setColumnName(int column,
String displayName)
|
void |
setColumnNames(String... columnNames)
|
void |
setValueAt(Object value,
int row,
int column)
|
String |
setValueSetter(String column,
String methodName)
|
| Methods inherited from class com.antelmann.util.table.AbstractObjectTableModel |
add, add, clear, contains, getList, getRelevantList, getRelevantListDescription, getRowCount, getRowFor, getRowValue, iterator, moveDown, moveUp, refreshContent, remove, remove, setColumnType, setColumnTypes, setRowValues, swap |
| Methods inherited from class javax.swing.table.AbstractTableModel |
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
PatternTableModel
public PatternTableModel()
PatternTableModel
public PatternTableModel(List<T> list)
addColumn
public void addColumn(String name,
PatternExtractor<? super T,?> pe)
addColumn
public <P> void addColumn(String name,
PatternExtractor<? super T,P> pe,
Class<? super P> type)
- this method is called by all other addColumn.. methods and provides most flexibility
as well as best performance depending on the efficient implementation of a given
PatternExtractor.
addColumn
public void addColumn(String columnName,
String methodName)
addColumn
public <R> void addColumn(String columnName,
String methodName,
Class<R> returnType)
- allows to easily add a column based on the method name.
While very convenient, the resulting
PatternExtractor is determining
the method via reflection upon each call of getValueAt(int, int), which
doesn't provide for the best performance.
Hence, for better performance you should consider using addColumn(String, Method),
which still uses reflection to invoke the method but at least doesn't have to determine
the method upon each call.
addColumn
public void addColumn(Class<T> entryType,
String columnName,
String methodOrFieldName,
boolean ensureAccessibility)
throws IllegalArgumentException
- convenience method
- Throws:
IllegalArgumentException- See Also:
addColumn(String, Method),
addColumn(String, Field)
addColumn
public <R> void addColumn(String name,
Method method)
throws IllegalArgumentException
- Throws:
IllegalArgumentException
addColumn
public <R> void addColumn(String name,
Field field)
removeColumn
public void removeColumn(int c)
throws IndexOutOfBoundsException
- Throws:
IndexOutOfBoundsException
removeColumn
public void removeColumn(String c)
throws IndexOutOfBoundsException
- Throws:
IndexOutOfBoundsException
getColumnCount
public int getColumnCount()
getColumnClass
public Class<?> getColumnClass(int column)
- Specified by:
getColumnClass in interface TableModel- Overrides:
getColumnClass in class AbstractObjectTableModel<T>
getValueAt
public Object getValueAt(int row,
int column)
getColumnName
public String getColumnName(int column)
- Specified by:
getColumnName in interface TableModel- Overrides:
getColumnName in class AbstractObjectTableModel<T>
setColumnNames
public void setColumnNames(String... columnNames)
throws UnsupportedOperationException
- Overrides:
setColumnNames in class AbstractObjectTableModel<T>
- Throws:
UnsupportedOperationException
setColumnName
public String setColumnName(int column,
String displayName)
throws UnsupportedOperationException
- Overrides:
setColumnName in class AbstractObjectTableModel<T>
- Throws:
UnsupportedOperationException
setValueSetter
public String setValueSetter(String column,
String methodName)
isCellEditable
public boolean isCellEditable(int row,
int column)
- Specified by:
isCellEditable in interface TableModel- Overrides:
isCellEditable in class AbstractTableModel
setValueAt
public void setValueAt(Object value,
int row,
int column)
- Specified by:
setValueAt in interface TableModel- Overrides:
setValueAt in class AbstractTableModel
- See Also:
setValueSetter(String, String)
findField
public static Field findField(Class<?> type,
String fieldName)
throws SecurityException,
NoSuchFieldException
- looks for the field in the declared class and its super classes
- Throws:
SecurityException
NoSuchFieldException
findMethod
public static Method findMethod(Class<?> type,
String methodName)
throws SecurityException,
NoSuchMethodException
- looks for the method with no arguments in the declared class and its super classes
- Throws:
SecurityException
NoSuchMethodException
(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads