Class KeypadData
java.lang.Object
org.osgi.service.dal.FunctionData
org.osgi.service.dal.functions.data.KeypadData
- All Implemented Interfaces:
Comparable<Object>
Represents a keypad event data that is collected when a change with some key
from the keypad has occurred.
The key pressed event is using TYPE_PRESSED
type, while the key
released event is using TYPE_RELEASED
type.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Represents the key code field name.static final String
Represents the key name field name.static final String
Represents the event sub-type field name.static final String
Represents the event type field name.static final int
Represents a keypad event sub-type for a double key pressed event.static final int
Represents a keypad event sub-type for a double long key pressed event.static final int
Represents a keypad event sub-type for a long key pressed event.static final int
Represents a keypad event sub-type for a normal key pressed event.static final int
Represents a keypad event type for a key pressed event.static final int
Represents a keypad event type for a key released event.Fields inherited from class org.osgi.service.dal.FunctionData
DESCRIPTION, FIELD_METADATA, FIELD_TIMESTAMP
-
Constructor Summary
ConstructorDescriptionKeypadData
(long timestamp, Map<String, Object> metadata, int type, int subType, int keyCode, String keyName) Constructs newKeypadData
instance with the specified arguments.KeypadData
(Map<String, ?> fields) Constructs newKeypadData
instance with the specified field values. -
Method Summary
Modifier and TypeMethodDescriptionint
Compares thisKeypadData
instance with the given argument.boolean
TwoKeypadData
instances are equal if they contain equal metadata, timestamp, event type, key code and key name.int
The code of the key.Represents a human readable name of the corresponding key code.int
Returns the event sub-type.int
getType()
Returns the event type.int
hashCode()
Returns the hash code for thisKeypadData
object.toString()
Returns the string representation of this keypad data.Methods inherited from class org.osgi.service.dal.FunctionData
getMetadata, getTimestamp
-
Field Details
-
FIELD_TYPE
Represents the event type field name. The field value is available withgetType()
. The field type isint
. The constant can be used as a key toKeypadData(Map)
.- See Also:
-
FIELD_SUB_TYPE
Represents the event sub-type field name. The field value is available withgetSubType()
. The field type isint
. The constant can be used as a key toKeypadData(Map)
.- See Also:
-
FIELD_KEY_CODE
Represents the key code field name. The field value is available withgetKeyCode()
. The field type isint
. The constant can be used as a key toKeypadData(Map)
.- See Also:
-
FIELD_KEY_NAME
Represents the key name field name. The field value is available withgetKeyName()
. The field type isString
. The constant can be used as a key toKeypadData(Map)
.- See Also:
-
TYPE_PRESSED
public static final int TYPE_PRESSEDRepresents a keypad event type for a key pressed event.- See Also:
-
TYPE_RELEASED
public static final int TYPE_RELEASEDRepresents a keypad event type for a key released event.- See Also:
-
SUB_TYPE_PRESSED_NORMAL
public static final int SUB_TYPE_PRESSED_NORMALRepresents a keypad event sub-type for a normal key pressed event. Usually, there is a single press and the key is not held down. This sub-type is used withTYPE_PRESSED
type.- See Also:
-
SUB_TYPE_PRESSED_LONG
public static final int SUB_TYPE_PRESSED_LONGRepresents a keypad event sub-type for a long key pressed event. Usually, there is a single press and the key is held down. This sub-type is used withTYPE_PRESSED
type.- See Also:
-
SUB_TYPE_PRESSED_DOUBLE
public static final int SUB_TYPE_PRESSED_DOUBLERepresents a keypad event sub-type for a double key pressed event. Usually, there are two press actions and the key is not held down after the second press. This sub-type is used withTYPE_PRESSED
type.- See Also:
-
SUB_TYPE_PRESSED_DOUBLE_LONG
public static final int SUB_TYPE_PRESSED_DOUBLE_LONGRepresents a keypad event sub-type for a double long key pressed event. Usually, there are two press actions and the key is held down after the second press. This sub-type is used withTYPE_PRESSED
type.- See Also:
-
-
Constructor Details
-
KeypadData
Constructs newKeypadData
instance with the specified field values. The map keys must match to the field names. The map values will be assigned to the appropriate class fields. For example, the maps can be: {"type"=Integer(1)...}. That map will initialize theFIELD_TYPE
field with 1.FIELD_TYPE
- mandatory field. The value type must beInteger
.FIELD_SUB_TYPE
- optional field. The value type must beInteger
.FIELD_KEY_CODE
- mandatory field. The value type must beInteger
.FIELD_KEY_NAME
- optional field. The value type must beString
.
- Parameters:
fields
- Contains the newKeypadData
instance field values.- Throws:
ClassCastException
- If the field value types are not expected.IllegalArgumentException
- If the event type or key code is missing or invalid arguments are specified.NullPointerException
- If the fields map isnull
.
-
KeypadData
public KeypadData(long timestamp, Map<String, Object> metadata, int type, int subType, int keyCode, String keyName) Constructs newKeypadData
instance with the specified arguments.- Parameters:
timestamp
- The data timestamp optional field.metadata
- The data metadata optional field.type
- The data event type mandatory field.subType
- The data event sub-type optional field or0
if there is no sub-type.keyCode
- The data key code mandatory field.keyName
- The data key name optional field ornull
if there is no key name.
-
-
Method Details
-
getType
public int getType()Returns the event type. The type represents the main reason for this event. It can be one of:- Returns:
- The event type.
-
getSubType
public int getSubType()Returns the event sub-type. The sub-type provides additional details about the event. The sub-type can be one of: Zero and positive values are reserved for this definition and further extensions of the sub-types. Custom sub-types can be used only as negative values to prevent potential collisions.- Returns:
- The event sub-type.
-
getKeyCode
public int getKeyCode()The code of the key. This field is mandatory and it holds the semantics(meaning) of the key.- Returns:
- The key code.
-
getKeyName
Represents a human readable name of the corresponding key code. This field is optional and sometimes it could be missed(might benull
).- Returns:
- A string with the name of the key or
null
if not specified.
-
equals
TwoKeypadData
instances are equal if they contain equal metadata, timestamp, event type, key code and key name.- Overrides:
equals
in classFunctionData
- Parameters:
o
- The object to compare this data.- Returns:
true
if this object is equivalent to the specified one.- See Also:
-
hashCode
public int hashCode()Returns the hash code for thisKeypadData
object. The hash code is a sum ofFunctionData.hashCode()
,String.hashCode()
, event type, event sub-type and key code, whereString.hashCode()
represents the key name hash code if available.- Overrides:
hashCode
in classFunctionData
- Returns:
- The hash code of this
LevelData
object. - See Also:
-
compareTo
Compares thisKeypadData
instance with the given argument. If the argument is notKeypadData
, it throwsClassCastException
. Otherwise, this method returns:-1
if this instance field is less than a field of the specified argument.0
if all fields are equivalent.1
if this instance field is greater than a field of the specified argument.
- Specified by:
compareTo
in interfaceComparable<Object>
- Overrides:
compareTo
in classFunctionData
- Parameters:
o
-KeypadData
to be compared.- Returns:
-1
,0
or1
depending on the comparison rules.- Throws:
ClassCastException
- If the method argument is not of typeKeypadData
.- See Also:
-
toString
Returns the string representation of this keypad data.
-