Package org.osgi.service.monitor
Class StatusVariable
- java.lang.Object
-
- org.osgi.service.monitor.StatusVariable
-
public final class StatusVariable extends java.lang.ObjectAStatusVariableobject represents the value of a status variable taken with a certain collection method at a certain point of time. The type of theStatusVariablecan beint,float,booleanorString.A
StatusVariableis identified by an ID string that is unique within the scope of aMonitorable. The ID must be a non-null, non-empty string that conforms to the "symbolic-name" definition in the OSGi core specification. This means that only the characters [-_.a-zA-Z0-9] may be used. The length of the ID must not exceed 32 bytes when UTF-8 encoded.
-
-
Field Summary
Fields Modifier and Type Field Description static intCM_CCConstant for identifying 'Cumulative Counter' data collection method.static intCM_DERConstant for identifying 'Discrete Event Registration' data collection method.static intCM_GAUGEConstant for identifying 'Gauge' data collection method.static intCM_SIConstant for identifying 'Status Inspection' data collection method.static intTYPE_BOOLEANConstant for identifyingbooleandata type.static intTYPE_FLOATConstant for identifyingfloatdata type.static intTYPE_INTEGERConstant for identifyingintdata type.static intTYPE_STRINGConstant for identifyingStringdata type.
-
Constructor Summary
Constructors Constructor Description StatusVariable(java.lang.String id, int cm, boolean data)Constructor for aStatusVariableofbooleantype.StatusVariable(java.lang.String id, int cm, float data)Constructor for aStatusVariableoffloattype.StatusVariable(java.lang.String id, int cm, int data)Constructor for aStatusVariableofinttype.StatusVariable(java.lang.String id, int cm, java.lang.String data)Constructor for aStatusVariableofStringtype.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)Compares the specified object with thisStatusVariable.booleangetBoolean()Returns theStatusVariablevalue if its type isboolean.intgetCollectionMethod()Returns the collection method of thisStatusVariable.floatgetFloat()Returns theStatusVariablevalue if its type isfloat.java.lang.StringgetID()Returns the ID of thisStatusVariable.intgetInteger()Returns theStatusVariablevalue if its type isint.java.lang.StringgetString()Returns theStatusVariablevalue if its type isString.java.util.DategetTimeStamp()Returns the timestamp associated with theStatusVariable.intgetType()Returns information on the data type of thisStatusVariable.inthashCode()Returns the hash code value for thisStatusVariable.java.lang.StringtoString()Returns aStringrepresentation of thisStatusVariable.
-
-
-
Field Detail
-
TYPE_INTEGER
public static final int TYPE_INTEGER
Constant for identifyingintdata type.- See Also:
- Constant Field Values
-
TYPE_FLOAT
public static final int TYPE_FLOAT
Constant for identifyingfloatdata type.- See Also:
- Constant Field Values
-
TYPE_STRING
public static final int TYPE_STRING
Constant for identifyingStringdata type.- See Also:
- Constant Field Values
-
TYPE_BOOLEAN
public static final int TYPE_BOOLEAN
Constant for identifyingbooleandata type.- See Also:
- Constant Field Values
-
CM_CC
public static final int CM_CC
Constant for identifying 'Cumulative Counter' data collection method.- See Also:
- Constant Field Values
-
CM_DER
public static final int CM_DER
Constant for identifying 'Discrete Event Registration' data collection method.- See Also:
- Constant Field Values
-
CM_GAUGE
public static final int CM_GAUGE
Constant for identifying 'Gauge' data collection method.- See Also:
- Constant Field Values
-
CM_SI
public static final int CM_SI
Constant for identifying 'Status Inspection' data collection method.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
StatusVariable
public StatusVariable(java.lang.String id, int cm, int data)Constructor for aStatusVariableofinttype.- Parameters:
id- the identifier of theStatusVariablecm- the collection method, one of theCM_constantsdata- theintvalue of theStatusVariable- Throws:
java.lang.IllegalArgumentException- if the givenidis not a validStatusVariablename, or ifcmis not one of the collection method constantsjava.lang.NullPointerException- if theidparameter isnull
-
StatusVariable
public StatusVariable(java.lang.String id, int cm, float data)Constructor for aStatusVariableoffloattype.- Parameters:
id- the identifier of theStatusVariablecm- the collection method, one of theCM_constantsdata- thefloatvalue of theStatusVariable- Throws:
java.lang.IllegalArgumentException- if the givenidis not a validStatusVariablename, or ifcmis not one of the collection method constantsjava.lang.NullPointerException- if theidparameter isnull
-
StatusVariable
public StatusVariable(java.lang.String id, int cm, boolean data)Constructor for aStatusVariableofbooleantype.- Parameters:
id- the identifier of theStatusVariablecm- the collection method, one of theCM_constantsdata- thebooleanvalue of theStatusVariable- Throws:
java.lang.IllegalArgumentException- if the givenidis not a validStatusVariablename, or ifcmis not one of the collection method constantsjava.lang.NullPointerException- if theidparameter isnull
-
StatusVariable
public StatusVariable(java.lang.String id, int cm, java.lang.String data)Constructor for aStatusVariableofStringtype.- Parameters:
id- the identifier of theStatusVariablecm- the collection method, one of theCM_constantsdata- theStringvalue of theStatusVariable, can benull- Throws:
java.lang.IllegalArgumentException- if the givenidis not a validStatusVariablename, or ifcmis not one of the collection method constantsjava.lang.NullPointerException- if theidparameter isnull
-
-
Method Detail
-
getID
public java.lang.String getID()
Returns the ID of thisStatusVariable. The ID is unique within the scope of aMonitorable.- Returns:
- the ID of this
StatusVariable
-
getType
public int getType()
Returns information on the data type of thisStatusVariable.- Returns:
- one of the
TYPE_constants indicating the type of thisStatusVariable
-
getTimeStamp
public java.util.Date getTimeStamp()
Returns the timestamp associated with theStatusVariable. The timestamp is stored when theStatusVariableinstance is created, generally during theMonitorable.getStatusVariable(String)method call.- Returns:
- the time when the
StatusVariablevalue was queried, cannot benull
-
getString
public java.lang.String getString() throws java.lang.IllegalStateExceptionReturns theStatusVariablevalue if its type isString.- Returns:
- the
StatusVariablevalue as aString - Throws:
java.lang.IllegalStateException- if the type of theStatusVariableis notString
-
getInteger
public int getInteger() throws java.lang.IllegalStateExceptionReturns theStatusVariablevalue if its type isint.- Returns:
- the
StatusVariablevalue as anint - Throws:
java.lang.IllegalStateException- if the type of thisStatusVariableis notint
-
getFloat
public float getFloat() throws java.lang.IllegalStateExceptionReturns theStatusVariablevalue if its type isfloat.- Returns:
- the
StatusVariablevalue as afloat - Throws:
java.lang.IllegalStateException- if the type of thisStatusVariableis notfloat
-
getBoolean
public boolean getBoolean() throws java.lang.IllegalStateExceptionReturns theStatusVariablevalue if its type isboolean.- Returns:
- the
StatusVariablevalue as aboolean - Throws:
java.lang.IllegalStateException- if the type of thisStatusVariableis notboolean
-
getCollectionMethod
public int getCollectionMethod()
Returns the collection method of thisStatusVariable. See section 3.3 b) in [ETSI TS 132 403]- Returns:
- one of the
CM_constants
-
equals
public boolean equals(java.lang.Object obj)
Compares the specified object with thisStatusVariable. TwoStatusVariableobjects are considered equal if their full path, collection method and type are identical, and the data (selected by their type) is equal.- Overrides:
equalsin classjava.lang.Object- Parameters:
obj- the object to compare with thisStatusVariable- Returns:
trueif the argument represents the sameStatusVariableas this object
-
hashCode
public int hashCode()
Returns the hash code value for thisStatusVariable. The hash code is calculated based on the full path, collection method and value of theStatusVariable.- Overrides:
hashCodein classjava.lang.Object- Returns:
- the hash code of this object
-
toString
public java.lang.String toString()
Returns aStringrepresentation of thisStatusVariable. The returnedStringcontains the full path, collection method, timestamp, type and value parameters of theStatusVariablein the following format:StatusVariable(<path>, <cm>, <timestamp>, <type>, <value>)
The collection method identifiers used in the string representation are "CC", "DER", "GAUGE" and "SI" (without the quotes). The format of the timestamp is defined by theDate.toStringmethod, while the type is identified by one of the strings "INTEGER", "FLOAT", "STRING" and "BOOLEAN". The final field contains the string representation of the value of the status variable.- Overrides:
toStringin classjava.lang.Object- Returns:
- the
Stringrepresentation of thisStatusVariable
-
-