com.ibm.as400.util.servlet
Class ListRowData

java.lang.Object
  extended by com.ibm.as400.util.servlet.RowData
      extended by com.ibm.as400.util.servlet.ListRowData
All Implemented Interfaces:
Serializable

public class ListRowData
extends RowData
implements Serializable

The ListRowData class represents a list of data.

The list of data is formatted into a series of rows where each row contains a finite number of columns determined by the ListMetaData object. Each column within a row contains an individual data item.

Here are some examples of what a ListRowData object can represent:

A ListRowData object maintains a position in the list that points to its current row of data. The initial position in the list is set before the first row. The next method moves to the next row in the list.

The getObject method is used to retrieve the column value for the current row indexed by the column number. Columns are numbered starting from 0.

The number, types, and properties of the list's columns are provided by the ListMetaData object returned by the getMetaData method.

ListRowData objects generate the following events:

The following example creates a ListRowData object and adds rows to represent a directory in the integrated file system.

  

// Get the files in a directory. AS400 mySystem = new AS400("mySystem.myCompany.com"); IFSFile f = new IFSFile(mySystem, pathName); FileListener listener = new FileListener(); f.list(listener); Vector files = listener.getFiles();

// Create a metadata object. ListMetaData metaData = new ListMetaData(4);

// Set first column to be the file name. metaData.setColumnName(0, "Name"); metaData.setColumnLabel(0, "Name"); metaData.setColumnType(0, RowMetaDataType.STRING_DATA_TYPE);

// Set second column to be the file size. metaData.setColumnName(1, "Size"); metaData.setColumnLabel(1, "Size"); metaData.setColumnType(1, RowMetaDataType.INTEGER_DATA_TYPE);

// Set third column to the file data/time stamp. metaData.setColumnName(2, "DateTime"); metaData.setColumnLabel(2, "Date/Time"); metaData.setColumnType(2, RowMetaDataType.STRING_DATA_TYPE);

// Set fourth column to the file type. metaData.setColumnName(3, "Type"); metaData.setColumnLabel(3, "Type"); metaData.setColumnType(3, RowMetaDataType.STRING_DATA_TYPE);

// Create a ListRowData object. ListRowData rowData = new ListRowData(); rowData.setMetaData(metaData);

// Add directory entries to list. for (int i=0; i < files.size(); i++) { Object[] row = new Object[4]; IFSFile file = (IFSFile)files.elementAt(i); row[0] = file.getName(); row[1] = new Long(file.length()); row[2] = new java.util.Date(file.lastModified()); if (file.isDirectory()) { row[3] = "Directory"; } else { row[3] = "File"; } rowData.addRow(row); }

See Also:
ListMetaData, Serialized Form

Field Summary
Modifier and Type Field and Description
 
Fields inherited from class com.ibm.as400.util.servlet.RowData
rowProperties_, rows_
 
Constructor Summary
Constructor and Description
ListRowData()
          Constructs a default ListRowData object.
ListRowData(RowMetaData metadata)
          Constructs a ListRowData object with the specified metadata.
 
Method Summary
Modifier and Type Method and Description
 void addRow(Object[] row)
          Adds the specified row to the list.
 void addRow(Object[] row, int rowIndex)
          Adds the specified row to the list at rowIndex.
 void addRow(Object[] row, Vector[] properties)
          Adds the specified row to the list.
 void addRow(Object[] row, Vector[] properties, int rowIndex)
          Adds the specified row to the list at rowIndex.
 void addRowDataListener(RowDataListener listener)
          Adds a RowDataListener.
 RowMetaData getMetaData()
          Returns the metadata.
 Object[] getRow()
          Returns the data objects for the current row.
 void removeRow(int rowIndex)
          Removes the row from the list at the specified rowIndex.
 void removeRowDataListener(RowDataListener listener)
          Removes this RowDataListener from the internal list.
 void setMetaData(RowMetaData metadata)
          Sets the metadata.
 void setRow(Object[] row, int rowIndex)
          Sets the row at the specified rowIndex to be the specified row.
 void setRow(Object[] row, Vector[] properties, int rowIndex)
          Sets the row at the specified rowIndex to be the specified row.
 
Methods inherited from class com.ibm.as400.util.servlet.RowData
absolute, addPropertyChangeListener, addVetoableChangeListener, afterLast, beforeFirst, first, getCurrentPosition, getObject, getObjectProperties, getRowProperties, isAfterLast, isBeforeFirst, isFirst, isLast, last, length, next, previous, relative, removePropertyChangeListener, removeVetoableChangeListener, setObjectProperties
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ListRowData

public ListRowData()
Constructs a default ListRowData object.


ListRowData

public ListRowData(RowMetaData metadata)
            throws RowDataException
Constructs a ListRowData object with the specified metadata.

Parameters:
metadata - The metadata.
Throws:
RowDataException - If a row data error occurs.
Method Detail

addRow

public void addRow(Object[] row)
            throws RowDataException
Adds the specified row to the list. The metadata needs to be set before adding a row to the list.

Parameters:
row - The row to be added.
Throws:
RowDataException - If the row length does not match the number of columns specified in the metadata.

addRow

public void addRow(Object[] row,
                   Vector[] properties)
            throws RowDataException
Adds the specified row to the list. Each object in the row is assigned a list of properties specified by properties. The metadata needs to be set before adding a row to the list.

Parameters:
row - The row to be added.
properties - The properties list.
Throws:
RowDataException - If the row length does not match the number of columns specified in the metadata.

addRow

public void addRow(Object[] row,
                   int rowIndex)
            throws RowDataException
Adds the specified row to the list at rowIndex. The metadata needs to be set before adding a row to the list.

Parameters:
row - The row.
rowIndex - The row index (0-based).
Throws:
RowDataException - If the row length does not match the number of columns specified in the metadata.

addRow

public void addRow(Object[] row,
                   Vector[] properties,
                   int rowIndex)
            throws RowDataException
Adds the specified row to the list at rowIndex. Each object in row is assigned a properties list specified by properties. The metadata needs to be set before adding a row to the list.

Parameters:
row - The row.
properties - The properties list.
rowIndex - The row index (0-based).
Throws:
RowDataException - If the row length does not match the number of columns specified in the metadata.

addRowDataListener

public void addRowDataListener(RowDataListener listener)
Adds a RowDataListener. The RowDataListener object is added to an internal list of RowDataListeners; it can be removed with removeRowDataListener.

Parameters:
listener - The RowDataListener.

getMetaData

public RowMetaData getMetaData()
Returns the metadata.

Specified by:
getMetaData in class RowData
Returns:
The metadata.

getRow

public Object[] getRow()
Returns the data objects for the current row.

Returns:
The row.

removeRow

public void removeRow(int rowIndex)
Removes the row from the list at the specified rowIndex.

Parameters:
rowIndex - The row index (0-based).

removeRowDataListener

public void removeRowDataListener(RowDataListener listener)
Removes this RowDataListener from the internal list. If the RowDataListener is not on the list, nothing is done.

Parameters:
listener - The RowDataListener.

setMetaData

public void setMetaData(RowMetaData metadata)
                 throws RowDataException,
                        PropertyVetoException
Sets the metadata.

Parameters:
metadata - The metadata.
Throws:
RowDataException - If a row data error occurs.
PropertyVetoException - If a change is vetoed.

setRow

public void setRow(Object[] row,
                   int rowIndex)
            throws RowDataException
Sets the row at the specified rowIndex to be the specified row.

Parameters:
row - The updated row.
rowIndex - The row index (0-based).
Throws:
RowDataException - If the row length does not match the number of columns specified in the metadata.

setRow

public void setRow(Object[] row,
                   Vector[] properties,
                   int rowIndex)
            throws RowDataException
Sets the row at the specified rowIndex to be the specified row. Each object in the row is assigned a properties list specified by properties.

Parameters:
row - The updated row.
properties - The properties list.
rowIndex - The row index (0-based).
Throws:
RowDataException - If the row length does not match the number of columns specified in the metadata.