Class ServerTableModel

java.lang.Object
javax.swing.table.AbstractTableModel
noaa.coastwatch.gui.open.ServerTableModel
All Implemented Interfaces:
Serializable, TableModel

public class ServerTableModel extends AbstractTableModel
The ServerTableModel class models a mapping of simple server names to URL strings. New servers may be added by entering valid data into the last row. The table always holds one more row than the actual number of server mappings so that users can use the last row to add a new server.
Since:
3.2.0
Author:
Peter Hollemans
See Also:
  • Constructor Details

    • ServerTableModel

      public ServerTableModel()
      Creates a new table model with no data.
    • ServerTableModel

      public ServerTableModel(List serverList)
      Creates a new table model using the server list.
  • Method Details

    • getRowCount

      public int getRowCount()
      Gets the number of table rows.
    • getColumnCount

      public int getColumnCount()
      Gets the number of table columns.
    • getValueAt

      public Object getValueAt(int row, int column)
      Gets the table data value.
    • getServerEntry

      public ServerTableModel.Entry getServerEntry(int row)
      Gets the server list entry at the specified row.
    • isCellEditable

      public boolean isCellEditable(int row, int column)
      Returns true except for the new entry because all the cells are editable.
      Specified by:
      isCellEditable in interface TableModel
      Overrides:
      isCellEditable in class AbstractTableModel
    • setValueAt

      public void setValueAt(Object value, int row, int column)
      Sets the value at the specified row and column.
      Specified by:
      setValueAt in interface TableModel
      Overrides:
      setValueAt in class AbstractTableModel
    • getColumnName

      public String getColumnName(int column)
      Gets the table column name.
      Specified by:
      getColumnName in interface TableModel
      Overrides:
      getColumnName in class AbstractTableModel
    • getServerList

      public List getServerList()
      Gets the list of server entries.
    • removeRow

      public void removeRow(int row)
      Removes the specified row from the table model.
    • readList

      public static List readList(InputStream stream) throws IOException
      Reads a list of ServerTableModel.Entry objects from the specified stream in XML format. The XML format is as follows:
         <?xml version="1.0" encoding="ISO-8859-1"?>
         <!DOCTYPE servertable SYSTEM "http://coastwatch.noaa.gov/xml/servertable.dtd">
         
         <servertable>
           <server name="Server 1" location="http://foo.bar.gov" />
           <server name="Server 2" location="http://fie.ont.gov" />
           <server name="Server 3" location="http://fiddle.sticks.gov" />
           ...
         </servertable>
      
      Parameters:
      stream - the input stream to read.
      Returns:
      the list of ServerTableModel.Entry objects.
      Throws:
      IOException - if the input had format errors.
    • writeList

      public static void writeList(OutputStream stream, List serverList)
      Writes a list of ServerTableModel.Entry objects to the specified stream in XML format. The XML format conforms to that of readList(java.io.InputStream).
      Parameters:
      stream - the output stream to write.
      serverList - the list of ServerTableModel.Entry objects.
    • main

      public static void main(String[] argv) throws Exception
      Tests this class.
      Parameters:
      argv - the array of command line parameters.
      Throws:
      Exception