com.isti.trinetwatch.params
Class DynamicParamHolder

java.lang.Object
  extended by com.isti.trinetwatch.params.DynamicParamHolder
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable

public class DynamicParamHolder
extends java.lang.Object
implements java.io.Serializable, java.lang.Comparable

Class DynamicParamHolder holds a 'DynamicParameter' object and adds support for rule-set and time-received operations. All functions are thread-synchronized to allow only one thread access at a time.

See Also:
Serialized Form

Constructor Summary
  DynamicParamHolder(Station stationObj, ParamValues paramValues, DynamicParameter dParam, AgentInfo agentObj, CriteriaTable critTable, long timeReceived)
          Constructor which builds a new 'DynamicParamHolder' object from an existing 'DynamicParameter' object.
  DynamicParamHolder(Station stationObj, ParamValues paramValues, DynamicParameter dParam, AgentInfo agentObj, CriteriaTable critTable, long timeReceived, ArchiveParameterFlag archiveParameterFlag)
          Constructor which builds a new 'DynamicParamHolder' object from an existing 'DynamicParameter' object.
protected DynamicParamHolder(Station stationObj, ParamValues paramValues, DynamicParameter dParam, AgentInfo agentObj, CriteriaTable critTable, long timeReceived, java.lang.String holderName, java.lang.Class dataClass, ArchiveParameterFlag archiveParameterFlag)
          Constructor which builds a new 'DynamicParamHolder' object from an existing 'DynamicParameter' object.
  DynamicParamHolder(Station stationObj, ParamValues paramValues, java.lang.String name, java.lang.Object data, AgentInfo agentObj, CriteriaTable critTable, long timeReceived)
          Constructor which initializes all values from scratch.
  DynamicParamHolder(Station stationObj, ParamValues paramValues, java.lang.String name, java.lang.Object data, AgentInfo agentObj, CriteriaTable critTable, long timeReceived, ArchiveParameterFlag archiveParameterFlag)
          Constructor which initializes all values from scratch.
 
Method Summary
static java.lang.String buildHolderName(java.lang.String name, AgentInfo agentObj)
          Returns the parameter 'holder' names, which includes the agent name.
 boolean changeCriteriaTable(CriteriaTable critTable)
          Changes the rule-set criteria table used by this dynamic parameter.
 void closeHistory()
          Closes the history tracking for this parameter, releasing resources allocated by its archive manager.
 int compareTo(java.lang.Object obj)
          Compares this object with the specified object 'obj'.
 AgentInfo getAgentObj()
          Returns the agent information block object associated with the source agent for this parameter.
 ArchiveParameterFlag getArchiveParameterFlag()
          Get the archive-parameter flag.
 CriteriaTable getCriteriaTable()
          Returns the 'CriteriaTable' object for this parameter.
 java.lang.Object getData()
          Returns data object.
 java.lang.Class getDataClass()
          Returns the class object associated with the data object.
protected static java.lang.Class getDataClass(CriteriaTable critTable)
          Gets the data class.
protected static java.lang.Class getDataClass(DynamicParameter dParam, CriteriaTable critTable)
          Gets the data class.
protected static java.lang.Class getDataClass(java.lang.Object data, CriteriaTable critTable)
          Gets the data class.
 DataStatusBlock getDataSnapshot(long dataTimeVal, long prefetchTimeVal, UsageLevelTag uLevelTagObj)
          Returns an historical "snapshot" of the parameter value at the given time value.
 DynamicParameter getDParameter()
          Returns the handle of the DynamicParameter object held by this object.
static boolean getHardHistoryFlag()
          Determines whether or not 'SoftReference' objects are used with the parameter history Vectors.
 java.util.Vector getHistoryVector(long startTime, long endTime)
          Returns a new Vector containing 'ValueTimeBlock' objects with timestamps in the specified range.
protected static java.lang.String getHolderName(DynamicParameter dParam, AgentInfo agentObj, CriteriaTable critTable, long timeReceived)
          Gets the holder name.
protected static java.lang.String getHolderName(java.lang.String name, AgentInfo agentObj)
          Gets the holder name.
 java.lang.String getName()
          Returns parameter name, with preceding agent name.
 java.lang.String getParamName()
          Returns parameter name, without preceding agent name.
 java.lang.Object getPrevDataValue()
          Returns the previous data value for the dynamic parameter.
 StatusLevelTag getPrevStatusLevel(UsageLevelTag uLevel)
          Returns the previous status level for the dynamic parameter.
 StatusLevelTag getStatusLevel(UsageLevelTag uLevel)
          Returns current status level for the dynamic parameter.
 long getTimeLastChanged()
          Returns the time of last change to the parameter value.
static void setHardHistoryFlag(boolean flg)
          Selects whether or not 'SoftReference' objects are used with the parameter history Vectors.
 void setTimeLastChanged(long timeVal)
          Sets the time of last change to the parameter value.
 java.lang.String toString()
          Returns string representation of data object.
 boolean updateFromNewestHistoryItem(long minTimeVal)
          Updates the parameter with the newest item in the parameter's history (if available).
 boolean updateParamValue(java.lang.Object data, long timeReceived)
          Updates the data object of the dynamic parameter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DynamicParamHolder

protected DynamicParamHolder(Station stationObj,
                             ParamValues paramValues,
                             DynamicParameter dParam,
                             AgentInfo agentObj,
                             CriteriaTable critTable,
                             long timeReceived,
                             java.lang.String holderName,
                             java.lang.Class dataClass,
                             ArchiveParameterFlag archiveParameterFlag)
Constructor which builds a new 'DynamicParamHolder' object from an existing 'DynamicParameter' object.

Parameters:
stationObj - the station object.
paramValues - parameter values.
dParam - 'DynamicParameter' object to build from.
agentObj - the agent information block object associated with the source agent for this parameter.
critTable - rule-set criteria table for dynamic parameter.
timeReceived - timestamp for dynamic parameter, or 0 to use current system time and not add initial value to history archive.
holderName - the holder name.
dataClass - the data class.
archiveParameterFlag - the archive-parameter flag.

DynamicParamHolder

public DynamicParamHolder(Station stationObj,
                          ParamValues paramValues,
                          DynamicParameter dParam,
                          AgentInfo agentObj,
                          CriteriaTable critTable,
                          long timeReceived,
                          ArchiveParameterFlag archiveParameterFlag)
Constructor which builds a new 'DynamicParamHolder' object from an existing 'DynamicParameter' object.

Parameters:
stationObj - the station object.
paramValues - parameter values.
dParam - 'DynamicParameter' object to build from.
agentObj - the agent information block object associated with the source agent for this parameter.
critTable - rule-set criteria table for dynamic parameter.
timeReceived - timestamp for dynamic parameter, or 0 to use current system time and not add initial value to history archive.
archiveParameterFlag - the archive-parameter flag.

DynamicParamHolder

public DynamicParamHolder(Station stationObj,
                          ParamValues paramValues,
                          DynamicParameter dParam,
                          AgentInfo agentObj,
                          CriteriaTable critTable,
                          long timeReceived)
Constructor which builds a new 'DynamicParamHolder' object from an existing 'DynamicParameter' object.

Parameters:
stationObj - the station object.
paramValues - parameter values.
dParam - 'DynamicParameter' object to build from.
agentObj - the agent information block object associated with the source agent for this parameter.
critTable - rule-set criteria table for dynamic parameter.
timeReceived - timestamp for dynamic parameter, or 0 to use current system time and not add initial value to history archive.

DynamicParamHolder

public DynamicParamHolder(Station stationObj,
                          ParamValues paramValues,
                          java.lang.String name,
                          java.lang.Object data,
                          AgentInfo agentObj,
                          CriteriaTable critTable,
                          long timeReceived,
                          ArchiveParameterFlag archiveParameterFlag)
Constructor which initializes all values from scratch.

Parameters:
stationObj - the station object.
paramValues - parameter values.
name - name of parameter.
data - data object, such as Integer, Double, String, etc.
agentObj - the agent information block object associated with the source agent for this parameter.
critTable - rule-set criteria table for dynamic parameter.
timeReceived - timestamp for dynamic parameter, or 0 to use current system time and not add initial value to history archive.
archiveParameterFlag - the archive-parameter flag.

DynamicParamHolder

public DynamicParamHolder(Station stationObj,
                          ParamValues paramValues,
                          java.lang.String name,
                          java.lang.Object data,
                          AgentInfo agentObj,
                          CriteriaTable critTable,
                          long timeReceived)
Constructor which initializes all values from scratch.

Parameters:
stationObj - the station object.
paramValues - parameter values.
name - name of parameter.
data - data object, such as Integer, Double, String, etc.
agentObj - the agent information block object associated with the source agent for this parameter.
critTable - rule-set criteria table for dynamic parameter.
timeReceived - timestamp for dynamic parameter, or 0 to use current system time and not add initial value to history archive.
Method Detail

getHolderName

protected static java.lang.String getHolderName(java.lang.String name,
                                                AgentInfo agentObj)
Gets the holder name.

Parameters:
name - name of parameter.
agentObj - the agent information block object associated with the source agent for this parameter.
Returns:
the holder name.

getHolderName

protected static java.lang.String getHolderName(DynamicParameter dParam,
                                                AgentInfo agentObj,
                                                CriteriaTable critTable,
                                                long timeReceived)
Gets the holder name.

Parameters:
dParam - 'DynamicParameter' object to build from.
agentObj - the agent information block object associated with the source agent for this parameter.
critTable - rule-set criteria table for dynamic parameter.
timeReceived - timestamp for dynamic parameter.
Returns:
the holder name.

getDataClass

protected static java.lang.Class getDataClass(CriteriaTable critTable)
Gets the data class.

Parameters:
critTable - rule-set criteria table for dynamic parameter.
Returns:
the data class.

getDataClass

protected static java.lang.Class getDataClass(DynamicParameter dParam,
                                              CriteriaTable critTable)
Gets the data class.

Parameters:
dParam - 'DynamicParameter' object to build from.
critTable - rule-set criteria table for dynamic parameter.
Returns:
the data class.

getDataClass

protected static java.lang.Class getDataClass(java.lang.Object data,
                                              CriteriaTable critTable)
Gets the data class.

Parameters:
data - data object, such as Integer, Double, String, etc.
critTable - rule-set criteria table for dynamic parameter.
Returns:
the data class.

changeCriteriaTable

public boolean changeCriteriaTable(CriteriaTable critTable)
Changes the rule-set criteria table used by this dynamic parameter.

Parameters:
critTable - rule-set criteria table to use.
Returns:
true if the rule-set change results in a parameter status level modification; false if not.

updateParamValue

public boolean updateParamValue(java.lang.Object data,
                                long timeReceived)
Updates the data object of the dynamic parameter.

Parameters:
data - data object, such as Integer, Double, String, etc.
timeReceived - the new timestamp for the dynamic parameter.
Returns:
true if the new data if different from the old, false if it is the same.

getDataClass

public java.lang.Class getDataClass()
Returns the class object associated with the data object.

Returns:
A 'Class' object, or 'null' if no data class has been established.

getStatusLevel

public StatusLevelTag getStatusLevel(UsageLevelTag uLevel)
Returns current status level for the dynamic parameter.

Parameters:
uLevel - the current usage level of the dynamic parameter.
Returns:
The StatusLevelTag object for the given usage level, or null if no criteria table entries exist for this parameter at the given usage level.

getDParameter

public DynamicParameter getDParameter()
Returns the handle of the DynamicParameter object held by this object.

Returns:
the handle of the DynamicParameter object held by this object.

getName

public java.lang.String getName()
Returns parameter name, with preceding agent name.

Returns:
parameter name, with preceding agent name.

getParamName

public java.lang.String getParamName()
Returns parameter name, without preceding agent name.

Returns:
parameter name, without preceding agent name.

getData

public java.lang.Object getData()
Returns data object.

Returns:
data object.

getAgentObj

public AgentInfo getAgentObj()
Returns the agent information block object associated with the source agent for this parameter.

Returns:
the agent information block object associated with the source agent for this parameter.

getCriteriaTable

public CriteriaTable getCriteriaTable()
Returns the 'CriteriaTable' object for this parameter.

Returns:
the 'CriteriaTable' object for this parameter.

toString

public java.lang.String toString()
Returns string representation of data object.

Overrides:
toString in class java.lang.Object
Returns:
string representation of data object.

compareTo

public int compareTo(java.lang.Object obj)
Compares this object with the specified object 'obj'. The 'data' field of this object is compared to the numeric representation of the specified object 'obj', as defined by its 'compareTo()' function.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
obj - an object to compare to.
Returns:
A negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
Throws:
java.lang.ClassCastException - if the specified object's type prevents it from being compared to this object.

getTimeLastChanged

public long getTimeLastChanged()
Returns the time of last change to the parameter value. (In seconds since January 1, 1970.)

Returns:
the time of last change to the parameter value.

setTimeLastChanged

public void setTimeLastChanged(long timeVal)
Sets the time of last change to the parameter value.

Parameters:
timeVal - new time of last change to the parameter value (in seconds since January 1, 1970).

getPrevDataValue

public java.lang.Object getPrevDataValue()
Returns the previous data value for the dynamic parameter.

Returns:
the previous data value for the dynamic parameter.

getPrevStatusLevel

public StatusLevelTag getPrevStatusLevel(UsageLevelTag uLevel)
Returns the previous status level for the dynamic parameter.

Parameters:
uLevel - the usage level of the dynamic parameter.
Returns:
The StatusLevelTag object for the given usage level, or null if no criteria table entries exist for this parameter at the given usage level.

getHistoryVector

public java.util.Vector getHistoryVector(long startTime,
                                         long endTime)
Returns a new Vector containing 'ValueTimeBlock' objects with timestamps in the specified range. The start and end time parameter values are in seconds since 1/1/1970, and are "inclusive".

Parameters:
startTime - the start time for the range, or 0 for the beginning of the history.
endTime - the end time for the range, or 0 for the end of the history.
Returns:
A Vector of 'ValueTimeBlock' objects with timestamps in the specified range, an empty Vector if no matching objects were found, or null if no history objects are available.

updateFromNewestHistoryItem

public boolean updateFromNewestHistoryItem(long minTimeVal)
Updates the parameter with the newest item in the parameter's history (if available).

Parameters:
minTimeVal - minimum-acceptable time value for update (seconds since 1/1/1970).
Returns:
true if a value was loaded from the paraemter's history; false if not.

getDataSnapshot

public DataStatusBlock getDataSnapshot(long dataTimeVal,
                                       long prefetchTimeVal,
                                       UsageLevelTag uLevelTagObj)
Returns an historical "snapshot" of the parameter value at the given time value. The returned 'DataStatusBlock' object will contain the data-value object and the status-level-tag object for the parameter at the given time. The status-level-tag object may be null (if no status level is available).

Parameters:
dataTimeVal - desired time value for data, in seconds since 1/1/1970.
prefetchTimeVal - time value for which archive data should be prefetched in search of the last entry before the 'dataTimeVal' time value (seconds since 1/1/1970).
uLevelTagObj - usage level for determining status level, or null for none.
Returns:
A new 'DataStatusBlock' object containing the data and status-level values, or null if no parameter history was available for the given time value.

closeHistory

public void closeHistory()
Closes the history tracking for this parameter, releasing resources allocated by its archive manager.


getArchiveParameterFlag

public ArchiveParameterFlag getArchiveParameterFlag()
Get the archive-parameter flag.

Returns:
the archive-parameter flag.

getHardHistoryFlag

public static boolean getHardHistoryFlag()
Determines whether or not 'SoftReference' objects are used with the parameter history Vectors. If used, the 'SoftReference' objects allow the history Vectors to be discarded when memory gets scarce. If not used then the history Vectors are never discarded.

Returns:
true if 'SoftReference' objects are used, false otherwise.

setHardHistoryFlag

public static void setHardHistoryFlag(boolean flg)
Selects whether or not 'SoftReference' objects are used with the parameter history Vectors. If used, the 'SoftReference' objects allow the history Vectors to be discarded when memory gets scarce. If not used then the history Vectors are never discarded.

Parameters:
flg - if true then 'SoftReference' objects are used.

buildHolderName

public static java.lang.String buildHolderName(java.lang.String name,
                                               AgentInfo agentObj)
Returns the parameter 'holder' names, which includes the agent name.

Parameters:
name - name of parameter.
agentObj - the agent information block object associated with the source agent for this parameter.
Returns:
the parameter 'holder' names, which includes the agent name.