com.isti.trinetwatch.station
Class StationTable

java.lang.Object
  extended bycom.isti.trinetwatch.station.StationTable
Direct Known Subclasses:
AgentInfo

public class StationTable
extends java.lang.Object

Class StationTable manages a table of Station objects (each object is associated with one station).


Field Summary
static java.lang.String LAT_LON_PREFIX_TEXT
          Extended lat/lon prefix text:
 
Constructor Summary
StationTable()
           
 
Method Summary
 boolean add(Station stationObj)
          Adds the given station object to the table.
 boolean addAll(StationTable srcTableObj)
          Adds the station objects from the given table to this table.
 boolean containsKey(java.lang.String name)
          Tests if a station with the specified short name exists in the table.
 boolean containsValue(Station stationObj)
          Tests if the given station object exists in the table.
 java.util.Enumeration elements()
          Returns an enumeration of station hash table values.
 void enterTableData(StationTable srcTableObj)
          Enters the data from the given table into this table.
 Station get(java.lang.String name)
          Returns the Station object in the table with the given short name.
 java.lang.String getDisplayString()
          Returns a display string containing basic information about all the stations in the table (and their fields), with each station on a separate line.
 java.lang.String getDisplayString(boolean cfgParamsFlag)
          Returns a display string containing information about all the stations in the table (and their fields), with each station on a separate line.
 java.util.Vector getKeysVector()
          Returns a new Vector containing the keys in the station hashtable.
 StatusLevelTag getSameStatusLevel()
          If all stations in the table have the same status level then it is returned; otherwise 'null' is returned.
 long getSameStatusTime()
          Returns the time associated with the last change to the value returned by 'getSameStatusLevel()', or zero if no changes have occurred.
 Station getStationForDParam(DynamicParamHolder dParam)
          Returns the station object that holds the given dynamic parameter object, or null if none could be found.
 java.lang.Object getThreadSyncObj()
          Returns the thread-synchronization object for this table.
 java.lang.String getUpdateString(long timeVal)
          Returns an update string of entries for all stations that have changed status or usage since the given time value.
 java.lang.String getUpdateString(java.lang.String agentName, long timeVal)
          Returns an update string of entries for all stations that have changed status or usage since the given time value.
 java.lang.String getUpdateString(java.lang.String agentName, long timeVal, boolean extendedFlag)
          Returns an update string of entries for all stations that have changed status or usage since the given time value.
 java.util.Vector getValuesVector()
          Returns a new Vector containing the values in the hashtable.
 java.util.Enumeration keys()
          Returns an enumeration of station hash table keys.
 void procSameStatusLevel()
          Tracks the status levels of the stations.
 Station remove(java.lang.String name)
          Removes the Station object in the table with the given short name.
 boolean removeAll(StationTable srcTableObj)
          Removes the station objects in the given table from this table.
 int stationCount()
          Returns a count of the number of station name keys in the table.
 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
 

Field Detail

LAT_LON_PREFIX_TEXT

public static final java.lang.String LAT_LON_PREFIX_TEXT
Extended lat/lon prefix text:

See Also:
Constant Field Values
Constructor Detail

StationTable

public StationTable()
Method Detail

add

public boolean add(Station stationObj)
Adds the given station object to the table.

Parameters:
stationObj - the station object.
Returns:
true if successful, false if a station with the same short name already exists in table or if the short name is invalid.

get

public Station get(java.lang.String name)
Returns the Station object in the table with the given short name.

Parameters:
name - the short name of the station.
Returns:
The handle of the Station object or null if no matching object was found.

remove

public Station remove(java.lang.String name)
Removes the Station object in the table with the given short name.

Parameters:
name - the short name of the station.
Returns:
The handle of the Station object that was removed or null if no matching object was found.

getThreadSyncObj

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

Returns:
The thread-synchronization object for this table.

addAll

public boolean addAll(StationTable srcTableObj)
Adds the station objects from the given table to this table.

Parameters:
srcTableObj - source table to read from.
Returns:
true if successful; false if any station objects failed to be added.

removeAll

public boolean removeAll(StationTable srcTableObj)
Removes the station objects in the given table from this table.

Parameters:
srcTableObj - source table.
Returns:
true if successful; false if any station objects failed to be removed.

enterTableData

public void enterTableData(StationTable srcTableObj)
Enters the data from the given table into this table. Existing station objects not in the given 'srcTableObj' are removed and matching station objects are updated.

Parameters:
srcTableObj - source table to read from.

containsKey

public boolean containsKey(java.lang.String name)
Tests if a station with the specified short name exists in the table.

Parameters:
name - the short name of the station.
Returns:
true if the station-name exists in the table, false if not.

containsValue

public boolean containsValue(Station stationObj)
Tests if the given station object exists in the table.

Parameters:
stationObj - the station object.
Returns:
true if the station object exists in the table, false if not.

keys

public java.util.Enumeration keys()
Returns an enumeration of station hash table keys. Each key will be the short name of a station.

Returns:
an enumeration of station hash table keys.

elements

public java.util.Enumeration elements()
Returns an enumeration of station hash table values. Each value will be a Station object. The data referenced by the returned enumeration will not be affected by later modifications to the table.

Returns:
an enumeration of station hash table values.

stationCount

public int stationCount()
Returns a count of the number of station name keys in the table.

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

getKeysVector

public java.util.Vector getKeysVector()
Returns a new Vector containing the keys in the station hashtable. Each key will be the short name of a station. The data in the the returned Vector will not be affected by later modifications to the hashtable, and the hashtable will not be affected by modifications to the returned Vector.

Returns:
a new Vector containing the keys in the station hashtable.

getValuesVector

public java.util.Vector getValuesVector()
Returns a new Vector containing the values in the hashtable. Each value will be a Station object. The data in the the returned Vector will not be affected by later modifications to the hashtable, and the hashtable will not be affected by modifications to the returned Vector.

Returns:
a new Vector containing the values in the hashtable.

getUpdateString

public java.lang.String getUpdateString(java.lang.String agentName,
                                        long timeVal)
Returns an update string of entries for all stations that have changed status or usage since the given time value.

Parameters:
agentName - the name of the agent to use in determining status, or null for no agent.
timeVal - a server epoch time value (seconds since 1/1/1970).
Returns:
An ASCII string formatted as follows: ;NNNN:SSSSS,UUUUU... where NNNN is a station name, SSSSS is a status level tag name, and UUUUU is a usage level tag name. Any number of station/status/usage groups may be passed.

getUpdateString

public java.lang.String getUpdateString(java.lang.String agentName,
                                        long timeVal,
                                        boolean extendedFlag)
Returns an update string of entries for all stations that have changed status or usage since the given time value.

Parameters:
agentName - the name of the agent to use in determining status, or null for no agent.
timeVal - a server epoch time value (seconds since 1/1/1970).
extendedFlag - true for extended information, false otherwise.
Returns:
An ASCII string formatted as follows: ;NNNN:SSSSS,UUUUU... or ;NNNN:SSSSS,UUUUU:LL=LAT,LON... if extended information is requested and it is available (all extended information is optional), where NNNN is a station name, SSSSS is a status level tag name, UUUUU is a usage level tag name, LAT is the station latitude and LON is the station longitude. For the final string in the information a termination of end of string, semi-colon (';') or colon (':') should be used. For example the usage level (UUUUU) text may be terminated by the end of the string, the semi-colon (';') for the next station or the colon (':') for the next extended information entry. The same is true for the last value of any extended extries such as the longitude (LON) entry if it is supplied. Any number of station/status/usage groups may be passed.

getUpdateString

public java.lang.String getUpdateString(long timeVal)
Returns an update string of entries for all stations that have changed status or usage since the given time value.

Parameters:
timeVal - a server epoch time value (seconds since 1/1/1970).
Returns:
An ASCII string formatted as follows: ;NNNN:SSSSS,UUUUU... where NNNN is a station name, SSSSS is a status level tag name, and UUUUU is a usage level tag name. Any number of station/status/usage groups may be passed.

getStationForDParam

public Station getStationForDParam(DynamicParamHolder dParam)
Returns the station object that holds the given dynamic parameter object, or null if none could be found.

Parameters:
dParam - the dynamic parameter object.
Returns:
the station object that holds the given dynamic parameter object, or null if none could be found.

procSameStatusLevel

public void procSameStatusLevel()
Tracks the status levels of the stations. This method should be called on a regular basis to keep track of when all of the stations have the same status level, thus allowing the 'getSameStatusLevel()' method to report the current status.


getSameStatusLevel

public StatusLevelTag getSameStatusLevel()
If all stations in the table have the same status level then it is returned; otherwise 'null' is returned. For this to work, the 'procSameStatusLevel()' method must be called on a regular basis.

Returns:
the status level if all stations in the table have the same status level, otherwise null.

getSameStatusTime

public long getSameStatusTime()
Returns the time associated with the last change to the value returned by 'getSameStatusLevel()', or zero if no changes have occurred.

Returns:
the time associated with the last change to the value returned by 'getSameStatusLevel()', or zero if no changes have occurred.

toString

public java.lang.String toString()
Returns a string representation of this object. The string contains the name of each station in the table.

Returns:
a string representation of this object. The string contains the name of each station in the table.

getDisplayString

public java.lang.String getDisplayString(boolean cfgParamsFlag)
Returns a display string containing information about all the stations in the table (and their fields), with each station on a separate line.

Parameters:
cfgParamsFlag - if true then each station's information from its table of configuration file parameters is also included.
Returns:
a display string containing information about all the stations in the table (and their fields), with each station on a separate line.

getDisplayString

public java.lang.String getDisplayString()
Returns a display string containing basic information about all the stations in the table (and their fields), with each station on a separate line. Information from each station's table of configuration file parameters is not included.

Returns:
a display string containing basic information about all the stations in the table (and their fields), with each station on a separate line. Information from each station's table of configuration file parameters is not included.