com.ibm.as400.util.servlet

Class ListRowData

  • All Implemented Interfaces:
    java.io.Serializable


    public class ListRowData
    extends RowData
    implements java.io.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 directory in the integrated file system.
    • A list of jobs.
    • A list of messages in a message queue.
    • A list of printers.
    • A list of spooled files.
    • A list of users.

    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:

    • RowDataEvent - The events fired are:
      • rowAdded()
      • rowChanged()
      • rowRemoved()

    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
    • 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(java.lang.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(java.lang.Object[] row,
                  java.util.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(java.lang.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(java.lang.Object[] row,
                  java.util.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.
      • getRow

        public java.lang.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,
                                java.beans.PropertyVetoException
        Sets the metadata.
        Parameters:
        metadata - The metadata.
        Throws:
        RowDataException - If a row data error occurs.
        java.beans.PropertyVetoException - If a change is vetoed.
      • setRow

        public void setRow(java.lang.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(java.lang.Object[] row,
                  java.util.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.