public class Happening extends AsyncEvent implements ActiveEvent<Happening,HappeningDispatcher>
Happenings
can be identified by an application-provided name
or a system-provided id
, both of which must be unique. A
system Happening
has a name provided by the system which
is a string beginning with @
.Constructor and Description |
---|
Happening(java.lang.String name)
Creates a happening with the given
name and the default dispatcher. |
Happening(java.lang.String name,
HappeningDispatcher dispatcher)
Creates a happening with the given name.
|
Modifier and Type | Method and Description |
---|---|
static int |
createId(java.lang.String name)
Sets up a mapping between a
name and a system-dependent ID. |
protected void |
finalize() |
static Happening |
get(int id)
Gets the external event corresponding to a given
id . |
static Happening |
get(java.lang.String name)
Gets the external event corresponding to a given name.
|
HappeningDispatcher |
getDispatcher()
Obtain the current dispatcher for this event.
|
static Happening |
getHappening(java.lang.String name)
Finds an active happening by its name.
|
int |
getId()
Gets the number of this happening.
|
static int |
getId(java.lang.String name)
Obtains the ID of
name , when one exists or
-1, when name is not registered. |
java.lang.String |
getName()
Gets the name of this happening.
|
boolean |
isActive()
Determines the activation state of this happening,
i.e., when it has been started.
|
static boolean |
isHappening(java.lang.String name)
Determines whether or not there is an active happening with
name
given as parameter. |
boolean |
isRunning()
Determines the firing state, releasing or skipping, of this signal,
i.e., whether or not it is active and enabled.
|
HappeningDispatcher |
setDispatcher(HappeningDispatcher dispatcher)
Change the current dispatcher for this event.
|
void |
start()
Starts this
happening , i.e., changes its state to the active and enabled. |
void |
start(boolean disabled)
Starts this
happening , but leaves it in the disabled state. |
boolean |
stop()
Stops this
happening from responding to the fire
and trigger methods. |
void |
trigger()
Causes the event dispatcher associated with
this
to be scheduled for execution. |
static boolean |
trigger(int id)
Causes the event dispatcher corresponding to
happeningId
to be scheduled for execution. |
addHandler, bindTo, createReleaseParameters, fire, handledBy, removeHandler, setHandler, unbindTo
addHandler, disable, enable, handledBy, hasHandlers, removeHandler, setHandler
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
disable, enable
public Happening(java.lang.String name, HappeningDispatcher dispatcher) throws StaticIllegalArgumentException
name
- A string to name the happening.dispatcher
- To use when being triggered.StaticIllegalArgumentException
- when
name
is null
or does not match the pattern
full identifier naming convention, i.e., package plus
name
. An implementation may throw this exception for
all names starting with java. and javax.public Happening(java.lang.String name) throws StaticIllegalArgumentException
name
and the default dispatcher.name
- A string to name the happening.StaticIllegalArgumentException
- when
name
is null
or does not match the pattern full
type naming convention, i.e., package plus name
.
An implementation may throw this exception for all names
starting with java. and javax.public static Happening getHappening(java.lang.String name)
name
- Identifies the happening to get.name
,
or null
, if no happening with the given name is found.StaticIllegalArgumentException
- when
name
is null
.public static boolean isHappening(java.lang.String name)
name
given as parameter.name
- A string that might name an active happening.true
only when there is a registered happening with the
given name
.StaticIllegalArgumentException
- when
name
is null
.public static int createId(java.lang.String name) throws StaticIllegalStateException
name
and a system-dependent ID.
This can be called either in native code that
sets up an interrupt service routine to link it with a
happening
. Once created, it cannot be removed.
This must take no more than linear time in the number of ID
(n
) registered, but should be O(log2(n))
.
name
- A string to name a happening.StaticIllegalStateException
- when
name
is already registered.StaticIllegalArgumentException
- when
name
is null
.public static int getId(java.lang.String name)
name
, when one exists or
-1, when name
is not registered.
This must take no more than linear time in the number of ID
(n
) registered, but should be O(log2(n))
.
name
- A happening name string.StaticIllegalArgumentException
- when
name
is null
.public static Happening get(int id)
id
.id
- The identifier of a registered signal.id
.public static Happening get(java.lang.String name)
name
- The name of a registered signal.name
.StaticIllegalArgumentException
- when
name
is null
.public static boolean trigger(int id)
happeningId
to be scheduled for execution. The implementation should be simple enough
so that it can be done in the context of an
interrupt service routine.
trigger()
and any native code analog to it interact
with other ActiveEvent
code effectively as
if trigger()
signals a POSIX counting semaphore that the
happening is waiting on.
The implementation is encouraged to create (and document) a native code analog to this method that can be used without a Java context.
This method must execute in constant time.
id
- Identifies which happening to trigger.true
when a happening with ID happeningId
was found, false
otherwise.public final int getId()
public java.lang.String getName()
public boolean isActive()
isActive
in interface ActiveEvent<Happening,HappeningDispatcher>
true
when active; false
otherwise.public boolean isRunning()
isRunning
in interface ActiveEvent<Happening,HappeningDispatcher>
isRunning
in class AsyncBaseEvent
true
when releasing, false
when skipping.public void start() throws StaticIllegalStateException
happening
, i.e., changes its state to the active and enabled.
Once a happening is started for the first time, when it is in a scoped
memory it increments the scope count of that scope; otherwise, it becomes
a member of the root set. An active and enabled happening dispatches its
handlers when fired.start
in interface ActiveEvent<Happening,HappeningDispatcher>
StaticIllegalStateException
- when this
happening
has already been started or its
name
is already in use by another happening that has
been started.stop()
public void start(boolean disabled) throws StaticIllegalStateException
happening
, but leaves it in the disabled state.
When fired before being enabled, it does not dispatch its handlers.start
in interface ActiveEvent<Happening,HappeningDispatcher>
disabled
- true for starting in a disabled state.StaticIllegalStateException
- when this
happening
has already been started.stop()
public boolean stop() throws StaticIllegalStateException
happening
from responding to the fire
and trigger
methods.stop
in interface ActiveEvent<Happening,HappeningDispatcher>
true
when this
is in the
enabled state; false
otherwise.StaticIllegalStateException
- when this
happening
is not active.public void trigger()
this
to be scheduled for execution. The implementation should be simple
enough so that it can be done in the context of an
interrupt service routine.
This method must execute in constant time.
public HappeningDispatcher getDispatcher()
ActiveEvent
getDispatcher
in interface ActiveEvent<Happening,HappeningDispatcher>
getDispatcher
in interface Releasable<Happening,HappeningDispatcher>
public HappeningDispatcher setDispatcher(HappeningDispatcher dispatcher)
ActiveEvent
dispatcher
is null
, the default dispatcher is restored.setDispatcher
in interface ActiveEvent<Happening,HappeningDispatcher>
protected void finalize() throws java.lang.Throwable
finalize
in class AsyncBaseEvent
java.lang.Throwable
aicas GmbH, Karlsruhe, Germany —www.aicas.com
Copyright © 2001-2024 aicas GmbH. All Rights Reserved.