public class ServerTableModel
extends javax.swing.table.AbstractTableModel
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.Modifier and Type | Class and Description |
---|---|
static class |
ServerTableModel.Entry
Holds a server table entry with server name and location.
|
Constructor and Description |
---|
ServerTableModel()
Creates a new table model with no data.
|
ServerTableModel(java.util.List serverList)
Creates a new table model using the server list.
|
Modifier and Type | Method and Description |
---|---|
int |
getColumnCount()
Gets the number of table columns.
|
java.lang.String |
getColumnName(int column)
Gets the table column name.
|
int |
getRowCount()
Gets the number of table rows.
|
ServerTableModel.Entry |
getServerEntry(int row)
Gets the server list entry at the specified row.
|
java.util.List |
getServerList()
Gets the list of server entries.
|
java.lang.Object |
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 |
main(java.lang.String[] argv)
Tests this class.
|
static java.util.List |
readList(java.io.InputStream stream)
Reads a list of
ServerTableModel.Entry objects from the specified stream
in XML format. |
void |
removeRow(int row)
Removes the specified row from the table model.
|
void |
setValueAt(java.lang.Object value,
int row,
int column)
Sets the value at the specified row and column.
|
static void |
writeList(java.io.OutputStream stream,
java.util.List serverList)
Writes a list of
ServerTableModel.Entry objects to the specified stream in
XML format. |
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getListeners, getTableModelListeners, removeTableModelListener
public ServerTableModel()
public ServerTableModel(java.util.List serverList)
public int getRowCount()
public int getColumnCount()
public java.lang.Object getValueAt(int row, int column)
public ServerTableModel.Entry getServerEntry(int row)
public boolean isCellEditable(int row, int column)
isCellEditable
in interface javax.swing.table.TableModel
isCellEditable
in class javax.swing.table.AbstractTableModel
public void setValueAt(java.lang.Object value, int row, int column)
setValueAt
in interface javax.swing.table.TableModel
setValueAt
in class javax.swing.table.AbstractTableModel
public java.lang.String getColumnName(int column)
getColumnName
in interface javax.swing.table.TableModel
getColumnName
in class javax.swing.table.AbstractTableModel
public java.util.List getServerList()
public void removeRow(int row)
public static java.util.List readList(java.io.InputStream stream) throws java.io.IOException
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>
stream
- the input stream to read.ServerTableModel.Entry
objects.java.io.IOException
- if the input had format errors.public static void writeList(java.io.OutputStream stream, java.util.List serverList)
ServerTableModel.Entry
objects to the specified stream in
XML format. The XML format conforms to that of readList(java.io.InputStream)
.stream
- the output stream to write.serverList
- the list of ServerTableModel.Entry
objects.public static void main(java.lang.String[] argv) throws java.lang.Exception
argv
- the array of command line parameters.java.lang.Exception