Class KeypadData

java.lang.Object
org.osgi.service.dal.FunctionData
org.osgi.service.dal.functions.data.KeypadData
All Implemented Interfaces:
Comparable<Object>

public class KeypadData extends FunctionData
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 Details

    • FIELD_TYPE

      public static final String FIELD_TYPE
      Represents the event type field name. The field value is available with getType(). The field type is int. The constant can be used as a key to KeypadData(Map).
      See Also:
    • FIELD_SUB_TYPE

      public static final String FIELD_SUB_TYPE
      Represents the event sub-type field name. The field value is available with getSubType(). The field type is int. The constant can be used as a key to KeypadData(Map).
      See Also:
    • FIELD_KEY_CODE

      public static final String FIELD_KEY_CODE
      Represents the key code field name. The field value is available with getKeyCode(). The field type is int . The constant can be used as a key to KeypadData(Map).
      See Also:
    • FIELD_KEY_NAME

      public static final String FIELD_KEY_NAME
      Represents the key name field name. The field value is available with getKeyName(). The field type is String. The constant can be used as a key to KeypadData(Map).
      See Also:
    • TYPE_PRESSED

      public static final int TYPE_PRESSED
      Represents a keypad event type for a key pressed event.
      See Also:
    • TYPE_RELEASED

      public static final int TYPE_RELEASED
      Represents a keypad event type for a key released event.
      See Also:
    • SUB_TYPE_PRESSED_NORMAL

      public static final int SUB_TYPE_PRESSED_NORMAL
      Represents 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 with TYPE_PRESSED type.
      See Also:
    • SUB_TYPE_PRESSED_LONG

      public static final int SUB_TYPE_PRESSED_LONG
      Represents 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 with TYPE_PRESSED type.
      See Also:
    • SUB_TYPE_PRESSED_DOUBLE

      public static final int SUB_TYPE_PRESSED_DOUBLE
      Represents 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 with TYPE_PRESSED type.
      See Also:
    • SUB_TYPE_PRESSED_DOUBLE_LONG

      public static final int SUB_TYPE_PRESSED_DOUBLE_LONG
      Represents 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 with TYPE_PRESSED type.
      See Also:
  • Constructor Details

    • KeypadData

      public KeypadData(Map<String,?> fields)
      Constructs new KeypadData 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 the FIELD_TYPE field with 1.
      Parameters:
      fields - Contains the new KeypadData 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 is null.
    • KeypadData

      public KeypadData(long timestamp, Map<String,Object> metadata, int type, int subType, int keyCode, String keyName)
      Constructs new KeypadData 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 or 0 if there is no sub-type.
      keyCode - The data key code mandatory field.
      keyName - The data key name optional field or null 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

      public String getKeyName()
      Represents a human readable name of the corresponding key code. This field is optional and sometimes it could be missed(might be null ).
      Returns:
      A string with the name of the key or null if not specified.
    • equals

      public boolean equals(Object o)
      Two KeypadData instances are equal if they contain equal metadata, timestamp, event type, key code and key name.
      Overrides:
      equals in class FunctionData
      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 this KeypadData object. The hash code is a sum of FunctionData.hashCode(), String.hashCode(), event type, event sub-type and key code, where String.hashCode() represents the key name hash code if available.
      Overrides:
      hashCode in class FunctionData
      Returns:
      The hash code of this LevelData object.
      See Also:
    • compareTo

      public int compareTo(Object o)
      Compares this KeypadData instance with the given argument. If the argument is not KeypadData, it throws ClassCastException. 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.
      The fields are compared in this order: timestamp, metadata, type, sub-type, key code, key name.
      Specified by:
      compareTo in interface Comparable<Object>
      Overrides:
      compareTo in class FunctionData
      Parameters:
      o - KeypadData to be compared.
      Returns:
      -1, 0 or 1 depending on the comparison rules.
      Throws:
      ClassCastException - If the method argument is not of type KeypadData.
      See Also:
    • toString

      public String toString()
      Returns the string representation of this keypad data.
      Overrides:
      toString in class Object
      Returns:
      The string representation of this keypad data.