Spec-Zone .ru
спецификации, руководства, описания, API
|
public class Event
extends java.util.EventObject
implements java.lang.Cloneable
Event
class.Modifier and Type | Field and Description |
---|---|
static EventType<Event> |
ANY
Common supertype for all event types.
|
protected boolean |
consumed
Whether this event has been consumed by any filter or handler.
|
protected EventType<? extends Event> |
eventType
Type of the event.
|
static EventTarget |
NULL_SOURCE_TARGET
The constant which represents an unknown event source / target.
|
protected EventTarget |
target
Event target that defines the path through which the event
will travel when posted.
|
Constructor and Description |
---|
Event(EventType<? extends Event> eventType)
Construct a new
Event with the specified event type. |
Event(java.lang.Object source,
EventTarget target,
EventType<? extends Event> eventType)
Construct a new
Event with the specified event source, target
and type. |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
clone()
Creates and returns a copy of this
Event . |
void |
consume()
Marks this
Event as consumed. |
Event |
copyFor(java.lang.Object newSource,
EventTarget newTarget)
Creates and returns a copy of this event with the specified event source
and target.
|
static void |
fireEvent(EventTarget eventTarget,
Event event)
Fires the specified event.
|
EventType<? extends Event> |
getEventType()
Gets the event type of this event.
|
EventTarget |
getTarget()
Returns the event target of this event.
|
boolean |
isConsumed()
Indicates whether this
Event has been consumed by any filter or
handler. |
public static final EventTarget NULL_SOURCE_TARGET
protected EventTarget target
protected boolean consumed
public Event(EventType<? extends Event> eventType)
Event
with the specified event type. The source
and target of the event is set to NULL_SOURCE_TARGET
.eventType
- the event typepublic Event(java.lang.Object source, EventTarget target, EventType<? extends Event> eventType)
Event
with the specified event source, target
and type. If the source or target is set to null
, it is replaced
by the NULL_SOURCE_TARGET
value.source
- the event source which sent the eventtarget
- the event target to associate with the eventeventType
- the event typepublic EventTarget getTarget()
public EventType<? extends Event> getEventType()
Event
class can have different event types. These event types further specify
what kind of event occurred.public Event copyFor(java.lang.Object newSource, EventTarget newTarget)
null
, it is
replaced by the NULL_SOURCE_TARGET
value.newSource
- the new source of the copied eventnewTarget
- the new target of the copied eventpublic boolean isConsumed()
Event
has been consumed by any filter or
handler.true
if this Event
has been consumed,
false
otherwisepublic void consume()
Event
as consumed. This stops its further propagation.public java.lang.Object clone()
Event
.clone
in class java.lang.Object
Event
with all values copied from
this Event
.public static void fireEvent(EventTarget eventTarget, Event event)
eventTarget
- the target for the eventevent
- the event to firejava.lang.NullPointerException
- if eventTarget or event is nullCopyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. Use is subject to