Class Event

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable
    Direct Known Subclasses:
    ActionEvent, PermissionEvent, SessionEvent

    public class Event
    extends java.lang.Object
    implements java.lang.Cloneable, java.io.Serializable
    Base class for custom events. Each event has associated an event source, event target and an event type.
    Since:
    1.4.0
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static EventType<Event> ANY
      Common supertype for all event types.
    • Constructor Summary

      Constructors 
      Constructor Description
      Event​(EventTarget<? extends Event> target)
      Construct a new Event with the specified event target.
      Event​(EventTarget<? extends Event> target, EventType<? extends Event> eventType)
      Construct a new Event with the specified event target and type.
      Event​(EventTarget<? extends Event> target, EventType<? extends Event> eventType, java.util.List<java.lang.Object> args)
      Construct a new Event with the specified event target, type and args.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method 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<? extends Event> newTarget)
      Creates and returns a copy of this event with the specified event source and target.
      boolean equals​(java.lang.Object o)  
      void fireEvent​(java.lang.Object source)
      Fires the event with the specified source.
      void fireEvent​(java.lang.Object source, java.lang.Object... args)
      Fires the event with the specified source and args.
      java.util.List<java.lang.Object> getArgs()
      Returns the Event arguments.
      EventType<? extends Event> getEventType()
      Gets the event type of this event.
      java.lang.Object getSource()
      The object on which the Event initially occurred.
      EventTarget<? extends Event> getTarget()
      Returns the event target of this event.
      int hashCode()  
      boolean isConsumed()
      Indicates whether this Event has been consumed by any filter or handler.
      protected void setSource​(java.lang.Object source)
      Sets the event source, only available to other event objects.
      protected void setTarget​(EventTarget<? extends Event> target)
      Sets the event target of this event, only available to other event objects.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • ANY

        public static final EventType<Event> ANY
        Common supertype for all event types.
    • Constructor Detail

      • Event

        public Event​(EventTarget<? extends Event> target)
        Construct a new Event with the specified event target.
        Parameters:
        target - the event target to associate with the event
      • Event

        public Event​(EventTarget<? extends Event> target,
                     EventType<? extends Event> eventType)
        Construct a new Event with the specified event target and type.
        Parameters:
        target - the event target to associate with the event
        eventType - the event type
      • Event

        public Event​(EventTarget<? extends Event> target,
                     EventType<? extends Event> eventType,
                     java.util.List<java.lang.Object> args)
        Construct a new Event with the specified event target, type and args.
        Parameters:
        target - the event target to associate with the event
        eventType - the event type
        args - arguments to make available to the EventHandler
    • Method Detail

      • getTarget

        public final EventTarget<? extends Event> getTarget()
        Returns the event target of this event. The event target specifies the path through which the event will travel when posted.
        Returns:
        the event target
      • setTarget

        protected final void setTarget​(EventTarget<? extends Event> target)
        Sets the event target of this event, only available to other event objects.
        Parameters:
        target - the event target
      • getEventType

        public EventType<? extends Event> getEventType()
        Gets the event type of this event. Objects of the same Event class can have different event types. These event types further specify what kind of event occurred.
        Returns:
        the event type
      • copyFor

        public Event copyFor​(java.lang.Object newSource,
                             EventTarget<? extends Event> newTarget)
        Creates and returns a copy of this event with the specified event source and target.
        Parameters:
        newSource - the new source of the copied event
        newTarget - the new target of the copied event
        Returns:
        the event copy with the new source and target
      • getSource

        public final java.lang.Object getSource()
        The object on which the Event initially occurred.
        Returns:
        the object on which the Event initially occurred.
      • setSource

        protected void setSource​(java.lang.Object source)
        Sets the event source, only available to other event objects.
        Parameters:
        source - the source to set
      • isConsumed

        public final boolean isConsumed()
        Indicates whether this Event has been consumed by any filter or handler.
        Returns:
        true if this Event has been consumed, false otherwise
      • consume

        public final void consume()
        Marks this Event as consumed. This stops its further propagation.
      • getArgs

        public final java.util.List<java.lang.Object> getArgs()
        Returns the Event arguments.
        Returns:
        the Event arguments
      • clone

        public final java.lang.Object clone()
        Creates and returns a copy of this Event.
        Overrides:
        clone in class java.lang.Object
        Returns:
        a new instance of Event with all values copied from this Event.
      • fireEvent

        public final void fireEvent​(java.lang.Object source)
        Fires the event with the specified source.
        Parameters:
        source - the event source which sent the event
      • fireEvent

        public final void fireEvent​(java.lang.Object source,
                                    java.lang.Object... args)
        Fires the event with the specified source and args.
        Parameters:
        source - the event source which sent the event
        args - a list of parameters to pass to the EventHandler
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object