com.isti.trinetwatch.station
Class GroupTable

java.lang.Object
  extended bycom.isti.trinetwatch.station.GroupTable
All Implemented Interfaces:
GroupTableInfo

public class GroupTable
extends java.lang.Object
implements GroupTableInfo

Class GroupTable manages a table of station groups.


Constructor Summary
GroupTable()
          Creates a manager for a table of stations groups.
GroupTable(StationTable mainStationsTable)
          Creates a manager for a table of stations groups.
 
Method Summary
 int add(Station stationObj, java.lang.String groupName)
          Adds the given Station object to the given group.
 boolean add(java.lang.String groupName, StationTable sTable)
          Adds a new group of stations to the table.
 boolean containsKey(java.lang.String groupName)
          Tests if the specified group name exists in the table.
 java.util.Enumeration elements()
          Returns an enumeration of the 'StationTable' objects in the table.
 void enterTableData(GroupTable srcGroupTableObj, StationTable mainStationsTable)
          Enters the data from the given table into this table.
 StationTable get(java.lang.String groupName)
          Returns the StationTable associated with the given group name.
 java.lang.String getDisplayString()
          Returns a display string containing information about all the groups in the table, with each group on a separate line.
 java.lang.String getGroupDisplayString(java.lang.String groupName)
          Returns a display string containing the name of each station in the specified group.
 java.util.Vector getKeysVector()
          Returns a Vector of group name keys.
 java.lang.String getStationsString(int compCode, java.lang.String groupName)
          Returns a String of names of stations associated with the given group name, via the given comparison code.
 StationTable getStationsTable(int compCode, java.lang.String groupName)
          Returns the StationTable associated with the given group name, via the given comparison code.
 java.lang.Object getThreadSyncObj()
          Returns the thread-synchronization object for this table.
 int groupCount()
          Returns a count of the number of group name keys in the table.
 java.util.Enumeration groupElements(java.lang.String groupName)
          Returns an enumeration of Station objects for the specified group.
 java.util.Enumeration groupKeys(java.lang.String groupName)
          Returns an enumeration of Station name keys for the specified group.
 java.util.Enumeration keys()
          Returns an enumeration of group name keys.
 void setMainStationsTable(StationTable mainStationsTable)
          Enters the "main" table of all stations for server.
 java.lang.String toString()
          Returns a string representation of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GroupTable

public GroupTable()
Creates a manager for a table of stations groups.


GroupTable

public GroupTable(StationTable mainStationsTable)
Creates a manager for a table of stations groups.

Parameters:
mainStationsTable - "main" table of all stations for server.
Method Detail

setMainStationsTable

public void setMainStationsTable(StationTable mainStationsTable)
Enters the "main" table of all stations for server.

Parameters:
mainStationsTable - "main" table of all stations for server.

add

public int add(Station stationObj,
               java.lang.String groupName)
Adds the given Station object to the given group. If the group does not previously exist then it is created.

Parameters:
stationObj - the station object to be added.
groupName - the name of the group to add to or create.
Returns:
0 if successful, value greater than 0 if the Station object already exists in the group or value less than 0 if either of the parameters is invalid.

add

public boolean add(java.lang.String groupName,
                   StationTable sTable)
Adds a new group of stations to the table.

Parameters:
groupName - the name of the group to add.
sTable - the table of stations to be associated with the given group name.
Returns:
true if successful, false if the group name already exists in the table or if either of the parameters is invalid.

getThreadSyncObj

public java.lang.Object getThreadSyncObj()
Returns the thread-synchronization object for this table.

Returns:
The thread-synchronization object for this table.

enterTableData

public void enterTableData(GroupTable srcGroupTableObj,
                           StationTable mainStationsTable)
Enters the data from the given table into this table.

Parameters:
srcGroupTableObj - source table to read from.
mainStationsTable - "main" stations table (containing the actual station objects rather than copies).

get

public StationTable get(java.lang.String groupName)
Returns the StationTable associated with the given group name.

Parameters:
groupName - name of the group to get.
Returns:
The associated StationTable object; or null if none found.

getStationsTable

public StationTable getStationsTable(int compCode,
                                     java.lang.String groupName)
Returns the StationTable associated with the given group name, via the given comparison code.

Specified by:
getStationsTable in interface GroupTableInfo
Parameters:
compCode - the comparison code associated with the group name (one of the GUIServicesDefines "PROP_CODE_..." values).
groupName - name of the group to get.
Returns:
The associated StationTable object; or null if none found.

getStationsString

public java.lang.String getStationsString(int compCode,
                                          java.lang.String groupName)
Returns a String of names of stations associated with the given group name, via the given comparison code.

Specified by:
getStationsString in interface GroupTableInfo
Parameters:
compCode - the comparison code associated with the group name (one of the GUIServicesDefines "PROP_CODE_..." values).
groupName - name of the group to get.
Returns:
A String of station name strings, each surrounded by double-quotes and separated by a comma; or an empty String if no station names could be generated.

containsKey

public boolean containsKey(java.lang.String groupName)
Tests if the specified group name exists in the table.

Parameters:
groupName - the name of the group to test.
Returns:
true if the group name exists in the table, false if not.

keys

public java.util.Enumeration keys()
Returns an enumeration of group name keys.

Specified by:
keys in interface GroupTableInfo
Returns:
an enumeration of group name keys.

getKeysVector

public java.util.Vector getKeysVector()
Returns a Vector of group name keys.

Returns:
a Vector of group name keys.

elements

public java.util.Enumeration elements()
Returns an enumeration of the 'StationTable' objects in the table. The data referenced by the the returned enumeration will not be affected by later modifications to the hashtable.

Specified by:
elements in interface GroupTableInfo
Returns:
an enumeration of the 'StationTable' objects in the table.

groupCount

public int groupCount()
Returns a count of the number of group name keys in the table.

Returns:
a count of the number of group name keys in the table.

groupKeys

public java.util.Enumeration groupKeys(java.lang.String groupName)
Returns an enumeration of Station name keys for the specified group.

Parameters:
groupName - the name of the group.
Returns:
An enumeration of Station name keys, or null if no group with the given name could be found in the group table.

groupElements

public java.util.Enumeration groupElements(java.lang.String groupName)
Returns an enumeration of Station objects for the specified group.

Parameters:
groupName - the name of the group.
Returns:
An enumeration of Station objects, or null if no group with the given name could be found in the group table.

toString

public java.lang.String toString()
Returns a string representation of this object. The string contains the list of group names, each separated by a space.

Returns:
a string representation of this object.

getGroupDisplayString

public java.lang.String getGroupDisplayString(java.lang.String groupName)
Returns a display string containing the name of each station in the specified group.

Parameters:
groupName - the name of the group.
Returns:
a display string containing the name of each station in the specified group, or an empty string if no matching group was found in the group table.

getDisplayString

public java.lang.String getDisplayString()
Returns a display string containing information about all the groups in the table, with each group on a separate line.

Returns:
a display string containing information about all the groups in the table, with each group on a separate line.