Holger's Java API

## com.antelmann.util.table
Class MethodTableModel<T>

    java.lang.Object
      javax.swing.table.AbstractTableModel
          com.antelmann.util.table.AbstractObjectTableModel<T>
              com.antelmann.util.table.MethodTableModel<T>

All Implemented Interfaces:
  ListRetriever<T>, Refreshable, ObjectTableModel<T>, Serializable, Iterable<T>, TableModel

Direct Known Subclasses:
  EmailTableModel

    public class MethodTableModel<T>

extends AbstractObjectTableModel<T>

a table model that displays/edits a list of objects based on the return value of given method names using reflection. This class also supports fields if no method name is available.

Author:
  Holger Antelmann
See Also:
  `PatternTableModel`, Serialized Form

Field Summary

Fields inherited from class com.antelmann.util.table.AbstractObjectTableModel
`columnNames, columnTypes`

Fields inherited from class javax.swing.table.AbstractTableModel
`listenerList`

Constructor Summary
`MethodTableModel(Class<T> classType, Collection<? extends T> col, String... methodNames)`
`MethodTableModel(Class<T> classType, String... methodNames)`

Method Summary

`static

`<T> String[]`

`

`allEditableFrom(Class<T> type)`

`static ArrayList<String>` `allFrom(Class<?> type)`
`Class<?>` `getColumnClass(int column)`
`int` `getColumnCount()`
`String` `getColumnName(int column)` returns the method name which may be altered according to Beans specifications (i.e.
`Class<T>` `getModelClass()` returns the class this model is base on
`AccessibleObject` `getRepresentationFor(int column)` returns either the method or the field associated with the given column
`String` `getSetterMethodName(int column)`
`Object` `getValueAt(int row, int column)`
`boolean` `isCellEditable(int row, int column)` returns true only if there is a method with a presumed setter name with a single argument and return type of void and no further settings apply
`boolean` `isColumnEditable(int column)`
`boolean` `isEnsureAccessibility()`
`boolean` `isReadOnly()` if true, all cells are read-only, regardless of other (column-specific) settings
`void` `refreshAll(Collection<? extends T> col, String... methodNames)` alters both: rows and columns
`void` `setEnsureAccessibility(boolean ensureAccessibility)`
`void` `setReadOnly(boolean readOnly)`
`void` `setReadOnlyColumns(int... columnIndex)`
`void` `setReadOnlyColumns(String... columnNames)`
`void` `setValueAt(Object value, int row, int column)` attempts to use a setter method to set the value

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, setColumnName, setColumnNames, 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`

Methods inherited from interface javax.swing.table.TableModel
`addTableModelListener, removeTableModelListener`

Constructor Detail

### MethodTableModel

    public MethodTableModel(Class<T> classType,
                            String... methodNames)

### MethodTableModel

    public MethodTableModel(Class<T> classType,
                            Collection<? extends T> col,
                            String... methodNames)
                     throws IllegalArgumentException

Throws:
  `IllegalArgumentException`

Method Detail

### allEditableFrom

    public static <T> String[] allEditableFrom(Class<T> type)

### allFrom

    public static ArrayList<String> allFrom(Class<?> type)

### getModelClass

    public Class<T> getModelClass()

  returns the class this model is base on

### isEnsureAccessibility

    public boolean isEnsureAccessibility()

### setEnsureAccessibility

    public void setEnsureAccessibility(boolean ensureAccessibility)

### getRepresentationFor

    public AccessibleObject getRepresentationFor(int column)

  returns either the method or the field associated with the given column

### refreshAll

    public void refreshAll(Collection<? extends T> col,
                           String... methodNames)
                    throws IllegalArgumentException

  alters both: rows and columns

  Throws:
    `IllegalArgumentException`

### getColumnCount

    public int getColumnCount()

### getValueAt

    public Object getValueAt(int row,
                             int column)

### isReadOnly

    public boolean isReadOnly()

  if true, all cells are read-only, regardless of other (column-specific) settings

### setReadOnly

    public void setReadOnly(boolean readOnly)

### setReadOnlyColumns

    public void setReadOnlyColumns(int... columnIndex)

### setReadOnlyColumns

    public void setReadOnlyColumns(String... columnNames)

### isCellEditable

    public boolean isCellEditable(int row,
                                  int column)

  returns true only if there is a method with a presumed setter name with a single argument and return type of void and no further settings apply

  Specified by:
    `isCellEditable` in interface `TableModel`
  Overrides:
    `isCellEditable` in class `AbstractTableModel`
  See Also:
    `setReadOnly(boolean)`, `setReadOnlyColumns(int...)`, `setReadOnlyColumns(String...)`

### isColumnEditable

    public boolean isColumnEditable(int column)

### getColumnName

    public String getColumnName(int column)

  returns the method name which may be altered according to Beans specifications (i.e. "is" and "get" is removed at the beginning if the following letter is upper-case) or the configured display name.

  Specified by:
    `getColumnName` in interface `TableModel`
  Overrides:
    `getColumnName` in class `AbstractObjectTableModel<T>`
  See Also:
    `AbstractObjectTableModel.setColumnName(int, String)`

### getColumnClass

    public Class<?> getColumnClass(int column)

  Specified by:
    `getColumnClass` in interface `TableModel`
  Overrides:
    `getColumnClass` in class `AbstractObjectTableModel<T>`

### setValueAt

    public void setValueAt(Object value,
                           int row,
                           int column)

  attempts to use a setter method to set the value

  Specified by:
    `setValueAt` in interface `TableModel`
  Overrides:
    `setValueAt` in class `AbstractTableModel`

### getSetterMethodName

    public String getSetterMethodName(int column)

(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads