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
Nested ClassesModifier and TypeClassDescriptionstatic classHolds a server table entry with server name and location. -
Field Summary
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new table model with no data.ServerTableModel(List serverList) Creates a new table model using the server list. -
Method Summary
Modifier and TypeMethodDescriptionintGets the number of table columns.getColumnName(int column) Gets the table column name.intGets 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.booleanisCellEditable(int row, int column) Returns true except for the new entry because all the cells are editable.static voidTests this class.static ListreadList(InputStream stream) Reads a list ofServerTableModel.Entryobjects from the specified stream in XML format.voidremoveRow(int row) Removes the specified row from the table model.voidsetValueAt(Object value, int row, int column) Sets the value at the specified row and column.static voidwriteList(OutputStream stream, List serverList) Writes a list ofServerTableModel.Entryobjects 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:
isCellEditablein interfaceTableModel- Overrides:
isCellEditablein classAbstractTableModel
-
setValueAt
Sets the value at the specified row and column.- Specified by:
setValueAtin interfaceTableModel- Overrides:
setValueAtin classAbstractTableModel
-
getColumnName
Gets the table column name.- Specified by:
getColumnNamein interfaceTableModel- Overrides:
getColumnNamein 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.Entryobjects 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.Entryobjects. - Throws:
IOException- if the input had format errors.
-
writeList
Writes a list ofServerTableModel.Entryobjects 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.Entryobjects.
-
main
Tests this class.- Parameters:
argv- the array of command line parameters.- Throws:
Exception
-