com.isti.trinetwatch.station
Class StationLevelsCache

java.lang.Object
  extended by com.isti.trinetwatch.station.StationLevelsCache

public class StationLevelsCache
extends java.lang.Object

Class StationLevelsCache manages a cache of station-levels entry objects.


Field Summary
protected  long cacheBaseTimeVal
           
protected  java.util.Vector entriesListObj
           
protected  StatusLevelTable statusLevelTableObj
           
protected  UsageLevelTable usageLevelTableObj
           
 
Constructor Summary
StationLevelsCache(long baseTimeVal, StatusLevelTable sLevelTableObj, UsageLevelTable uLevelTableObj)
          Creates a cache of station-levels entry objects.
 
Method Summary
 void addEntry(long timeVal, StatusLevelTag sLevelObj, UsageLevelTag uLevelObj)
          Adds an entry to the cache.
 StationLevelsEntry get(int idx)
          Fetches the entry object at the given index in the cache.
 java.lang.String getLevelsAtTimeStr(long timeVal)
          Returns a string containing the status and usage level names for the given time value.
 void purgeOldEntries(long timeVal)
          Purges entries from the cache that are older than the given time value.
 int size()
          Returns the number of entries in the cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cacheBaseTimeVal

protected final long cacheBaseTimeVal

statusLevelTableObj

protected final StatusLevelTable statusLevelTableObj

usageLevelTableObj

protected final UsageLevelTable usageLevelTableObj

entriesListObj

protected final java.util.Vector entriesListObj
Constructor Detail

StationLevelsCache

public StationLevelsCache(long baseTimeVal,
                          StatusLevelTable sLevelTableObj,
                          UsageLevelTable uLevelTableObj)
Creates a cache of station-levels entry objects.

Parameters:
baseTimeVal - base time value for cache (seconds since 1/1/1970).
sLevelTableObj - status-level table for cache.
uLevelTableObj - usage-level table for cache.
Method Detail

addEntry

public void addEntry(long timeVal,
                     StatusLevelTag sLevelObj,
                     UsageLevelTag uLevelObj)
              throws java.lang.IllegalArgumentException
Adds an entry to the cache. If the given values are equal to the values of the last entry in the cache then a new entry is not added.

Parameters:
timeVal - time value associated with levels (seconds since 1/1/1970).
sLevelObj - status-level object.
uLevelObj - usage-level object.
Throws:
java.lang.IllegalArgumentException - if index value for given status or usage level is out of range.

getLevelsAtTimeStr

public java.lang.String getLevelsAtTimeStr(long timeVal)
Returns a string containing the status and usage level names for the given time value.

Parameters:
timeVal - requested time value (seconds since 1/1/1970).
Returns:
An ASCII string formatted as follows: SSSSS,UUUUU where SSSSS is the status level tag name and UUUUU is the usage level tag name.

purgeOldEntries

public void purgeOldEntries(long timeVal)
Purges entries from the cache that are older than the given time value. The newest older item is left in the cache (so it is available for the 'getLevelsAtTimeStr()' method).

Parameters:
timeVal - purge time value (seconds since 1/1/1970).

size

public int size()
Returns the number of entries in the cache.

Returns:
The number of entries in the cache.

get

public StationLevelsEntry get(int idx)
Fetches the entry object at the given index in the cache.

Parameters:
idx - index value to use.
Returns:
The 'StationLevelsEntry' object at the given index value, or null if the index value is out of range.