Class EventPermission

  extended by java.security.Permission
      extended by javax.microedition.event.EventPermission

public final class EventPermission
extends java.security.Permission

EventPermission allows access to system events. An EventPermission objects contains a name (also referred to as a "target name") and actions.

The target name is the name of the event ("BATTERY_LEVEL", "com.MyCompany.MyEvent", etc). The naming convention follows the hierarchical property naming convention and are explained in the package description. An asterisk MAY appear at the end of the event name, following a ".", or by itself, to signify a wildcard match. For example: "com.MyCompany.*" or "*" is valid, but "*MyCompany" or "a*b" is not valid.

The actions to be granted are passed to the constructor in a String containing a list of one or more comma-separated keywords. The possible keywords are "post", "read" and "register". Their meaning is defined as follows:

post Permission to post an event. Allows the EventManager.post method to post an event.
read Permission to read an event. Allows the EventManager.getCurrent method return the current event.
register Permission to register applications to launch in response to events. Allows the EventManager.registerApplication() method to register for the named event.

The actions string is converted to lowercase before processing.

Care should be taken before granting application permission to access certain events. For example, granting permission to post events could allow a badly behaving application to interfere with the operation of the device.

MIDP 3.0

Constructor Summary
EventPermission(java.lang.String event, java.lang.String actions)
          Creates a new EventPermission object with the specified name and actions.
Method Summary
 boolean equals(java.lang.Object object)
          Checks if another object is "equal" to this one.
 java.lang.String getActions()
          Gets the canonical string representing the actions.
 int hashCode()
          Gets the hash code value for this object.
 boolean implies(java.security.Permission p)
          Checks if the specified permission is "implied" by this object.
Methods inherited from class java.security.Permission
getName, newPermissionCollection, toString
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait

Constructor Detail


public EventPermission(java.lang.String event,
                       java.lang.String actions)
Creates a new EventPermission object with the specified name and actions.

event - The name of the event for which to grant permission.
actions - Valid actions are "post", "read" and "register".
java.lang.NullPointerException - if event or actions is null.
java.lang.IllegalArgumentException - if actions is empty or includes any string other than those allowed.
See Also:
Method Detail


public boolean implies(java.security.Permission p)
Checks if the specified permission is "implied" by this object. Returns true if:

Specified by:
implies in class java.security.Permission
p - the permission to check against.
true if the passed permission is equal to or implied by this permission, false otherwise.


public java.lang.String getActions()
Gets the canonical string representing the actions. This method always returns present actions in the following order: "post", "read" and "register". For example, if this EventPermission object allows both post and read actions, a call to getActions will return the string "post,read".

Specified by:
getActions in class java.security.Permission
the canonical string of actions.


public int hashCode()
Gets the hash code value for this object.

Specified by:
hashCode in class java.security.Permission
the hashcode


public boolean equals(java.lang.Object object)
Checks if another object is "equal" to this one.

Specified by:
equals in class java.security.Permission
object - an object to compare
true if the objects are of the same type and the event and action are equal.


Send a comment or suggestionVersion 3.0 of Mobile Information Device Profile Specification
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries. Copyright 2002-2009 Motorola Inc. Portions copyright 1993-2002 Sun Microsystems, Inc. and Motorola, Inc. All Rights Reserved.