Package org.osgi.service.monitor
Class StatusVariable
- java.lang.Object
-
- org.osgi.service.monitor.StatusVariable
-
public final class StatusVariable extends java.lang.Object
AStatusVariable
object represents the value of a status variable taken with a certain collection method at a certain point of time. The type of theStatusVariable
can beint
,float
,boolean
orString
.A
StatusVariable
is 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 int
CM_CC
Constant for identifying 'Cumulative Counter' data collection method.static int
CM_DER
Constant for identifying 'Discrete Event Registration' data collection method.static int
CM_GAUGE
Constant for identifying 'Gauge' data collection method.static int
CM_SI
Constant for identifying 'Status Inspection' data collection method.static int
TYPE_BOOLEAN
Constant for identifyingboolean
data type.static int
TYPE_FLOAT
Constant for identifyingfloat
data type.static int
TYPE_INTEGER
Constant for identifyingint
data type.static int
TYPE_STRING
Constant for identifyingString
data type.
-
Constructor Summary
Constructors Constructor Description StatusVariable(java.lang.String id, int cm, boolean data)
Constructor for aStatusVariable
ofboolean
type.StatusVariable(java.lang.String id, int cm, float data)
Constructor for aStatusVariable
offloat
type.StatusVariable(java.lang.String id, int cm, int data)
Constructor for aStatusVariable
ofint
type.StatusVariable(java.lang.String id, int cm, java.lang.String data)
Constructor for aStatusVariable
ofString
type.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
Compares the specified object with thisStatusVariable
.boolean
getBoolean()
Returns theStatusVariable
value if its type isboolean
.int
getCollectionMethod()
Returns the collection method of thisStatusVariable
.float
getFloat()
Returns theStatusVariable
value if its type isfloat
.java.lang.String
getID()
Returns the ID of thisStatusVariable
.int
getInteger()
Returns theStatusVariable
value if its type isint
.java.lang.String
getString()
Returns theStatusVariable
value if its type isString
.java.util.Date
getTimeStamp()
Returns the timestamp associated with theStatusVariable
.int
getType()
Returns information on the data type of thisStatusVariable
.int
hashCode()
Returns the hash code value for thisStatusVariable
.java.lang.String
toString()
Returns aString
representation of thisStatusVariable
.
-
-
-
Field Detail
-
TYPE_INTEGER
public static final int TYPE_INTEGER
Constant for identifyingint
data type.- See Also:
- Constant Field Values
-
TYPE_FLOAT
public static final int TYPE_FLOAT
Constant for identifyingfloat
data type.- See Also:
- Constant Field Values
-
TYPE_STRING
public static final int TYPE_STRING
Constant for identifyingString
data type.- See Also:
- Constant Field Values
-
TYPE_BOOLEAN
public static final int TYPE_BOOLEAN
Constant for identifyingboolean
data 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 aStatusVariable
ofint
type.- Parameters:
id
- the identifier of theStatusVariable
cm
- the collection method, one of theCM_
constantsdata
- theint
value of theStatusVariable
- Throws:
java.lang.IllegalArgumentException
- if the givenid
is not a validStatusVariable
name, or ifcm
is not one of the collection method constantsjava.lang.NullPointerException
- if theid
parameter isnull
-
StatusVariable
public StatusVariable(java.lang.String id, int cm, float data)
Constructor for aStatusVariable
offloat
type.- Parameters:
id
- the identifier of theStatusVariable
cm
- the collection method, one of theCM_
constantsdata
- thefloat
value of theStatusVariable
- Throws:
java.lang.IllegalArgumentException
- if the givenid
is not a validStatusVariable
name, or ifcm
is not one of the collection method constantsjava.lang.NullPointerException
- if theid
parameter isnull
-
StatusVariable
public StatusVariable(java.lang.String id, int cm, boolean data)
Constructor for aStatusVariable
ofboolean
type.- Parameters:
id
- the identifier of theStatusVariable
cm
- the collection method, one of theCM_
constantsdata
- theboolean
value of theStatusVariable
- Throws:
java.lang.IllegalArgumentException
- if the givenid
is not a validStatusVariable
name, or ifcm
is not one of the collection method constantsjava.lang.NullPointerException
- if theid
parameter isnull
-
StatusVariable
public StatusVariable(java.lang.String id, int cm, java.lang.String data)
Constructor for aStatusVariable
ofString
type.- Parameters:
id
- the identifier of theStatusVariable
cm
- the collection method, one of theCM_
constantsdata
- theString
value of theStatusVariable
, can benull
- Throws:
java.lang.IllegalArgumentException
- if the givenid
is not a validStatusVariable
name, or ifcm
is not one of the collection method constantsjava.lang.NullPointerException
- if theid
parameter 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 theStatusVariable
instance is created, generally during theMonitorable.getStatusVariable(String)
method call.- Returns:
- the time when the
StatusVariable
value was queried, cannot benull
-
getString
public java.lang.String getString() throws java.lang.IllegalStateException
Returns theStatusVariable
value if its type isString
.- Returns:
- the
StatusVariable
value as aString
- Throws:
java.lang.IllegalStateException
- if the type of theStatusVariable
is notString
-
getInteger
public int getInteger() throws java.lang.IllegalStateException
Returns theStatusVariable
value if its type isint
.- Returns:
- the
StatusVariable
value as anint
- Throws:
java.lang.IllegalStateException
- if the type of thisStatusVariable
is notint
-
getFloat
public float getFloat() throws java.lang.IllegalStateException
Returns theStatusVariable
value if its type isfloat
.- Returns:
- the
StatusVariable
value as afloat
- Throws:
java.lang.IllegalStateException
- if the type of thisStatusVariable
is notfloat
-
getBoolean
public boolean getBoolean() throws java.lang.IllegalStateException
Returns theStatusVariable
value if its type isboolean
.- Returns:
- the
StatusVariable
value as aboolean
- Throws:
java.lang.IllegalStateException
- if the type of thisStatusVariable
is 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
. TwoStatusVariable
objects are considered equal if their full path, collection method and type are identical, and the data (selected by their type) is equal.- Overrides:
equals
in classjava.lang.Object
- Parameters:
obj
- the object to compare with thisStatusVariable
- Returns:
true
if the argument represents the sameStatusVariable
as 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:
hashCode
in classjava.lang.Object
- Returns:
- the hash code of this object
-
toString
public java.lang.String toString()
Returns aString
representation of thisStatusVariable
. The returnedString
contains the full path, collection method, timestamp, type and value parameters of theStatusVariable
in 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.toString
method, 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:
toString
in classjava.lang.Object
- Returns:
- the
String
representation of thisStatusVariable
-
-