Package org.osgi.service.monitor
Class StatusVariable
java.lang.Object
org.osgi.service.monitor.StatusVariable
A
StatusVariable object represents the value of a status variable
taken with a certain collection method at a certain point of time. The type
of the StatusVariable can be int, float,
boolean or String.
A StatusVariable is identified by an ID string that is unique within
the scope of a Monitorable. 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
FieldsModifier and TypeFieldDescriptionprivate booleanprivate intstatic final intConstant for identifying 'Cumulative Counter' data collection method.static final intConstant for identifying 'Discrete Event Registration' data collection method.static final intConstant for identifying 'Gauge' data collection method.static final intConstant for identifying 'Status Inspection' data collection method.private floatprivate Stringprivate int(package private) static final intprivate String(package private) static final Stringprivate Dateprivate intstatic final intConstant for identifyingbooleandata type.static final intConstant for identifyingfloatdata type.static final intConstant for identifyingintdata type.static final intConstant for identifyingStringdata type. -
Constructor Summary
ConstructorsConstructorDescriptionStatusVariable(String id, int cm, boolean data) Constructor for aStatusVariableofbooleantype.StatusVariable(String id, int cm, float data) Constructor for aStatusVariableoffloattype.StatusVariable(String id, int cm, int data) Constructor for aStatusVariableofinttype.StatusVariable(String id, int cm, String data) Constructor for aStatusVariableofStringtype. -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidprivate static booleancontainsValidChars(String name) booleanCompares the specified object with thisStatusVariable.private booleanbooleanReturns theStatusVariablevalue if its type isboolean.intReturns the collection method of thisStatusVariable.floatgetFloat()Returns theStatusVariablevalue if its type isfloat.getID()Returns the ID of thisStatusVariable.intReturns theStatusVariablevalue if its type isint.Returns theStatusVariablevalue if its type isString.Returns the timestamp associated with theStatusVariable.intgetType()Returns information on the data type of thisStatusVariable.inthashCode()Returns the hash code value for thisStatusVariable.private intprivate voidtoString()Returns aStringrepresentation of thisStatusVariable.
-
Field Details
-
TYPE_INTEGER
public static final int TYPE_INTEGERConstant for identifyingintdata type.- See Also:
-
TYPE_FLOAT
public static final int TYPE_FLOATConstant for identifyingfloatdata type.- See Also:
-
TYPE_STRING
public static final int TYPE_STRINGConstant for identifyingStringdata type.- See Also:
-
TYPE_BOOLEAN
public static final int TYPE_BOOLEANConstant for identifyingbooleandata type.- See Also:
-
CM_CC
public static final int CM_CCConstant for identifying 'Cumulative Counter' data collection method.- See Also:
-
CM_DER
public static final int CM_DERConstant for identifying 'Discrete Event Registration' data collection method.- See Also:
-
CM_GAUGE
public static final int CM_GAUGEConstant for identifying 'Gauge' data collection method.- See Also:
-
CM_SI
public static final int CM_SIConstant for identifying 'Status Inspection' data collection method.- See Also:
-
SYMBOLIC_NAME_CHARACTERS
- See Also:
-
MAX_ID_LENGTH
static final int MAX_ID_LENGTH- See Also:
-
id
-
timeStamp
-
cm
private int cm -
type
private int type -
intData
private int intData -
floatData
private float floatData -
stringData
-
booleanData
private boolean booleanData
-
-
Constructor Details
-
StatusVariable
Constructor for aStatusVariableofinttype.- Parameters:
id- the identifier of theStatusVariablecm- the collection method, one of theCM_constantsdata- theintvalue of theStatusVariable- Throws:
IllegalArgumentException- if the givenidis not a validStatusVariablename, or ifcmis not one of the collection method constantsNullPointerException- if theidparameter isnull
-
StatusVariable
Constructor for aStatusVariableoffloattype.- Parameters:
id- the identifier of theStatusVariablecm- the collection method, one of theCM_constantsdata- thefloatvalue of theStatusVariable- Throws:
IllegalArgumentException- if the givenidis not a validStatusVariablename, or ifcmis not one of the collection method constantsNullPointerException- if theidparameter isnull
-
StatusVariable
Constructor for aStatusVariableofbooleantype.- Parameters:
id- the identifier of theStatusVariablecm- the collection method, one of theCM_constantsdata- thebooleanvalue of theStatusVariable- Throws:
IllegalArgumentException- if the givenidis not a validStatusVariablename, or ifcmis not one of the collection method constantsNullPointerException- if theidparameter isnull
-
StatusVariable
Constructor for aStatusVariableofStringtype.- Parameters:
id- the identifier of theStatusVariablecm- the collection method, one of theCM_constantsdata- theStringvalue of theStatusVariable, can benull- Throws:
IllegalArgumentException- if the givenidis not a validStatusVariablename, or ifcmis not one of the collection method constantsNullPointerException- if theidparameter isnull
-
-
Method Details
-
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
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
Returns theStatusVariablevalue if its type isString.- Returns:
- the
StatusVariablevalue as aString - Throws:
IllegalStateException- if the type of theStatusVariableis notString
-
getInteger
Returns theStatusVariablevalue if its type isint.- Returns:
- the
StatusVariablevalue as anint - Throws:
IllegalStateException- if the type of thisStatusVariableis notint
-
getFloat
Returns theStatusVariablevalue if its type isfloat.- Returns:
- the
StatusVariablevalue as afloat - Throws:
IllegalStateException- if the type of thisStatusVariableis notfloat
-
getBoolean
Returns theStatusVariablevalue if its type isboolean.- Returns:
- the
StatusVariablevalue as aboolean - Throws:
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
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. -
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. -
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. -
setCommon
-
equals
-
hashCode
-
checkId
private static void checkId(String id, String idName) throws IllegalArgumentException, NullPointerException -
containsValidChars
-