All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.ibm.as400.vaccess.RecordListTableModel

java.lang.Object
   |
   +----com.sun.java.swing.table.AbstractTableModel
           |
           +----com.ibm.as400.vaccess.RecordListTableModel

public class RecordListTableModel
extends AbstractTableModel
implements Serializable
The RecordListTableModel class represents a table that contains the records of an AS/400 file using record-level access. This model can be used to create a table of the results.

This class should be used by users who wish to change the default interface for the table. When the default look and behavior is sufficient, RecordListTablePane can be used.

Users must call close() to ensure that the AS/400 resources are properly freed when this model is no longer needed.

The data in the model is retrieved from the system when load() is called. If load() is not called, the model will contain no data. Not all data is retrieved at once, rather data is retrieved as needed (in chunks), to improve performance.

The data in this model is not editable. The individual cell values cannot be changed.

Most errors are reported by firing ErrorEvents, rather than throwing exceptions. Users should listen for ErrorEvents in order to diagnose and recover from error conditions.

RecordListTableModel objects generate the following events:

// Set up table for file contents.
AS400 system = new AS400("MySystem", "Userid", "Password");
String file = "/QSYS.LIB/QGPL.LIB/MyFile.FILE";
final RecordListTableModel model = new RecordListTableModel(system, file);
// Set up window to hold table
JFrame frame = new JFrame ("My Window");
WindowListener l = new WindowAdapter()
{
// Close the model when window is closed.
public void windowClosing(WindowEvent e)
{
model.close();
}
};
frame.addWindowListener(l);
// Set up the error dialog adapter.
model.addErrorListener (new ErrorDialogAdapter (frame));
// Add the component and get data from system.
model.load();
JTable table = new JTable(model);
frame.getContentPane().add(new JScrollPane(table));
// Display the window
frame.setVisible(true)


Variable Index

 o KEY_EQ
Constant indicating search type of equal.
 o KEY_GE
Constant indicating search type of greater than or equal.
 o KEY_GT
Constant indicating search type of greater than.
 o KEY_LE
Constant indicating search type of less than or equal.
 o KEY_LT
Constant indicating search type of less than.

Constructor Index

 o RecordListTableModel()
Constructs a RecordListTableModel object.
 o RecordListTableModel(AS400, String)
Constructs a RecordListTableModel object.
 o RecordListTableModel(AS400, String, Object[], int)
Constructs a RecordListTableModel object.

Method Index

 o addErrorListener(ErrorListener)
Adds a listener to be notified when an error occurs.
 o addPropertyChangeListener(PropertyChangeListener)
Adds a listener to be notified when the value of any bound property is changed.
 o addVetoableChangeListener(VetoableChangeListener)
Adds a listener to be notified when the value of any constrained property is changed.
 o addWorkingListener(WorkingListener)
Adds a listener to be notified when work starts and stops on potentially long-running operations.
 o close()
Closes the AS400 file this model represents.
 o getColumnClass(int)
Returns the class of the values in the column.
 o getColumnCount()
Returns the number of columns in the table.
 o getColumnID(int)
Returns the identifier of the column.
 o getColumnName(int)
Returns the name of the column for use in a table heading.
 o getColumnWidth(int)
Returns the width of a column as a character count.
 o getFileName()
Returns the file name.
 o getKey()
Returns the key.
 o getKeyed()
Returns whether the file will be accessed in key or sequential order.
 o getRowCount()
Returns the number of rows in the table.
 o getSearchType()
Returns the search type.
 o getSystem()
Returns the AS400 where the file is located.
 o getValueAt(int, int)
Returns the value at the specifed column and row.
 o load()
Loads the table based on the state of the system.
 o removeErrorListener(ErrorListener)
Removes a listener from being notified when an error occurs.
 o removePropertyChangeListener(PropertyChangeListener)
Removes a listener from being notified when the value of any bound property is changed.
 o removeVetoableChangeListener(VetoableChangeListener)
Removes a listener from being notified when the value of any constrained property is changed.
 o removeWorkingListener(WorkingListener)
Removes a listener from being notified when work starts and stops on potentially long-running operations.
 o setFileName(String)
Sets the name of the file.
 o setKey(Object[])
Sets the key.
 o setKeyed(boolean)
Sets whether the file will be accessed in key or sequential order.
 o setSearchType(int)
Sets the search type.
 o setSystem(AS400)
Sets the AS400 where the file is located.

Variables

 o KEY_EQ
 public static final int KEY_EQ
Constant indicating search type of equal.

 o KEY_GT
 public static final int KEY_GT
Constant indicating search type of greater than.

 o KEY_GE
 public static final int KEY_GE
Constant indicating search type of greater than or equal.

 o KEY_LT
 public static final int KEY_LT
Constant indicating search type of less than.

 o KEY_LE
 public static final int KEY_LE
Constant indicating search type of less than or equal.

Constructors

 o RecordListTableModel
 public RecordListTableModel()
Constructs a RecordListTableModel object. This constructor sets the keyed property to false.

 o RecordListTableModel
 public RecordListTableModel(AS400 system,
                             String fileName)
Constructs a RecordListTableModel object. This constructor sets the keyed property to false.

Parameters:
system - The AS400 where the file is located.
fileName - The file name. The name is specified as a fully qualified path name in the library file system.
 o RecordListTableModel
 public RecordListTableModel(AS400 system,
                             String fileName,
                             Object key[],
                             int searchType)
Constructs a RecordListTableModel object. This constructor sets the keyed property to true.

Parameters:
system - The AS400 where the file is located.
fileName - The keyed file name. The name is specified as a fully qualified path name in the library file system.
key - The values which make up the key with which to find the record. This value may be null.
searchType - Constant indicating the type of match required.

Methods

 o addErrorListener
 public void addErrorListener(ErrorListener listener)
Adds a listener to be notified when an error occurs. The listener's errorOccurred() method will be called.

Parameters:
listener - The listener.
 o addPropertyChangeListener
 public void addPropertyChangeListener(PropertyChangeListener listener)
Adds a listener to be notified when the value of any bound property is changed. The listener's propertyChange() method will be called.

Parameters:
listener - The listener.
 o addVetoableChangeListener
 public void addVetoableChangeListener(VetoableChangeListener listener)
Adds a listener to be notified when the value of any constrained property is changed. The listener's vetoableChange() method will be called.

Parameters:
listener - The listener.
 o addWorkingListener
 public void addWorkingListener(WorkingListener listener)
Adds a listener to be notified when work starts and stops on potentially long-running operations.

Parameters:
listener - The listener.
 o close
 public void close()
Closes the AS400 file this model represents.

 o getColumnClass
 public synchronized Class getColumnClass(int columnIndex)
Returns the class of the values in the column. If an error occurs, null is returned.

Parameters:
columnIndex - The index of the column. Indices start at 0.
Returns:
The class of the column values.
Overrides:
getColumnClass in class AbstractTableModel
 o getColumnCount
 public synchronized int getColumnCount()
Returns the number of columns in the table.

Returns:
The number of columns in the table.
Overrides:
getColumnCount in class AbstractTableModel
 o getColumnID
 public synchronized String getColumnID(int columnIndex)
Returns the identifier of the column. This is the field name in the database. If an error occurs, null is returned.

Parameters:
columnIndex - The index of the column. Indices start at 0.
Returns:
The column identifier.
 o getColumnName
 public synchronized String getColumnName(int columnIndex)
Returns the name of the column for use in a table heading. If an error occurs, null is returned.

Parameters:
columnIndex - The index of the column. Indices start at 0.
Returns:
The column name.
Overrides:
getColumnName in class AbstractTableModel
 o getColumnWidth
 public synchronized int getColumnWidth(int columnIndex)
Returns the width of a column as a character count. If an error occurs, 0 is returned.

Parameters:
columnIndex - The index of the column. Indices start at 0.
Returns:
The width of the column expressed as a character count.
 o getFileName
 public String getFileName()
Returns the file name. The name is formatted as a fully qualified path name in the library file system.

Returns:
The file name.
 o getKey
 public Object[] getKey()
Returns the key. The key is only used if the keyed property is true.

Returns:
The key.
 o getKeyed
 public boolean getKeyed()
Returns whether the file will be accessed in key or sequential order.

Returns:
true if the file will be accessed in key order; false if the file will be accessed in sequential order.
 o getRowCount
 public synchronized int getRowCount()
Returns the number of rows in the table. Because of incremental data retrieval, this value may not be accurate.

Returns:
The number of rows in the table.
Overrides:
getRowCount in class AbstractTableModel
 o getSearchType
 public int getSearchType()
Returns the search type. The search type is only used if the keyed property is true and the key property is not null.

Returns:
The search type.
 o getSystem
 public AS400 getSystem()
Returns the AS400 where the file is located.

Returns:
The AS400 where the file is located.
 o getValueAt
 public Object getValueAt(int rowIndex,
                          int columnIndex)
Returns the value at the specifed column and row. If an error occurs, null is returned.

Parameters:
rowIndex - The row index. Values start at 0.
columnIndex - The column index. Values start at 0.
Returns:
The value at the specified column and row.
Overrides:
getValueAt in class AbstractTableModel
 o load
 public void load()
Loads the table based on the state of the system. The system and fileName properties must be set before this method is called.

 o removeErrorListener
 public void removeErrorListener(ErrorListener listener)
Removes a listener from being notified when an error occurs.

Parameters:
listener - The listener.
 o removePropertyChangeListener
 public void removePropertyChangeListener(PropertyChangeListener listener)
Removes a listener from being notified when the value of any bound property is changed.

Parameters:
listener - The listener.
 o removeVetoableChangeListener
 public void removeVetoableChangeListener(VetoableChangeListener listener)
Removes a listener from being notified when the value of any constrained property is changed.

Parameters:
listener - The listener.
 o removeWorkingListener
 public void removeWorkingListener(WorkingListener listener)
Removes a listener from being notified when work starts and stops on potentially long-running operations.

Parameters:
listener - The listener.
 o setFileName
 public void setFileName(String fileName) throws PropertyVetoException
Sets the name of the file. This property is bound and constrained. Note that the data will not change until a load() is done.

Parameters:
fileName - The file name. The name is specified as a fully qualified path name in the library file system.
Throws: PropertyVetoException
If the change is vetoed.
 o setKey
 public void setKey(Object key[]) throws PropertyVetoException
Sets the key. This property is bound and constrained. Note that the data will not change until a load() is done. The key is only used if the keyed property is true.

Parameters:
key - The values which make up the key with which to find the record. This value may be null.
Throws: PropertyVetoException
If the change is vetoed.
 o setKeyed
 public void setKeyed(boolean keyed) throws PropertyVetoException
Sets whether the file will be accessed in key or sequential order. This property is bound and constrained. Note that the data in will not change until a load() is done.

Parameters:
keyed - true if the file will be accessed in key order; false if the file will be accessed in sequential order.
Throws: PropertyVetoException
If the change is vetoed.
 o setSearchType
 public void setSearchType(int searchType) throws PropertyVetoException
Sets the search type. This property is bound and constrained. Note that the data will not change until a load() is done. The default is KEY_EQ. The search type is only used if the keyed property is true and the key property is not null.

Parameters:
searchType - Constant indicating the type of match required.
Throws: PropertyVetoException
If the change is vetoed.
 o setSystem
 public void setSystem(AS400 system) throws PropertyVetoException
Sets the AS400 where the file is located. This property is bound and constrained. Note that the data will not change until a load() is done.

Parameters:
system - The AS400 where the file is located.
Throws: PropertyVetoException
If the change is vetoed.

All Packages  Class Hierarchy  This Package  Previous  Next  Index