Package noaa.coastwatch.gui.open
Class ServerTableModel
java.lang.Object
javax.swing.table.AbstractTableModel
noaa.coastwatch.gui.open.ServerTableModel
- All Implemented Interfaces:
Serializable
,TableModel
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:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Holds a server table entry with server name and location. -
Field Summary
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
-
Constructor Summary
ConstructorDescriptionCreates a new table model with no data.ServerTableModel
(List serverList) Creates a new table model using the server list. -
Method Summary
Modifier and TypeMethodDescriptionint
Gets the number of table columns.getColumnName
(int column) Gets the table column name.int
Gets the number of table rows.getServerEntry
(int row) Gets the server list entry at the specified row.Gets the list of server entries.getValueAt
(int row, int column) Gets the table data value.boolean
isCellEditable
(int row, int column) Returns true except for the new entry because all the cells are editable.static void
Tests this class.static List
readList
(InputStream stream) Reads a list ofServerTableModel.Entry
objects from the specified stream in XML format.void
removeRow
(int row) Removes the specified row from the table model.void
setValueAt
(Object value, int row, int column) Sets the value at the specified row and column.static void
writeList
(OutputStream stream, List serverList) Writes a list ofServerTableModel.Entry
objects to the specified stream in XML format.Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getListeners, getTableModelListeners, removeTableModelListener
-
Constructor Details
-
ServerTableModel
public ServerTableModel()Creates a new table model with no data. -
ServerTableModel
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
Gets the table data value. -
getServerEntry
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 interfaceTableModel
- Overrides:
isCellEditable
in classAbstractTableModel
-
setValueAt
Sets the value at the specified row and column.- Specified by:
setValueAt
in interfaceTableModel
- Overrides:
setValueAt
in classAbstractTableModel
-
getColumnName
Gets the table column name.- Specified by:
getColumnName
in interfaceTableModel
- Overrides:
getColumnName
in classAbstractTableModel
-
getServerList
Gets the list of server entries. -
removeRow
public void removeRow(int row) Removes the specified row from the table model. -
readList
Reads a list ofServerTableModel.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
Writes a list ofServerTableModel.Entry
objects to the specified stream in XML format. The XML format conforms to that ofreadList(java.io.InputStream)
.- Parameters:
stream
- the output stream to write.serverList
- the list ofServerTableModel.Entry
objects.
-
main
Tests this class.- Parameters:
argv
- the array of command line parameters.- Throws:
Exception
-