org.springframework.webflow
Class Event

java.lang.Object
  extended by java.util.EventObject
      extended by org.springframework.webflow.Event
All Implemented Interfaces:
java.io.Serializable, org.springframework.binding.AttributeSource
Direct Known Subclasses:
ExternalEvent

public class Event
extends java.util.EventObject
implements org.springframework.binding.AttributeSource

Signals the occurence of something a webflow should respond to. Each event has a string id that provides a key for what happened: e.g "coinInserted", or "pinDropped". An event may optionally contain information about the state in which it occured, e.g "displayVendingMachine" or "waitForUser". Events may have parameters that provide arbitrary payload data, e.g. "coin.amount=25", or "pinDropSpeed=25ms".

For example, a "submit" event might signal that a Submit button was pressed in a web browser. A "success" event might signal an action executed successfully. A "finish" event might signal a sub flow ended normally.

Why is this not an interface? A specific design choice. An event is not a strategy, its essentially a parmaeter object and it is expected that specializations of this base class be "Events" and not part of some other inheritence hierarchy.

Author:
Keith Donald, Erwin Vervaet
See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.EventObject
source
 
Constructor Summary
Event(java.lang.Object source)
          Constructs a new event with the specified source.
Event(java.lang.Object source, java.lang.String id)
          Create a new event with the specified id.
Event(java.lang.Object source, java.lang.String id, java.util.Map parameters)
          Create a new event with the specified id and the provided contextual parameters.
Event(java.lang.Object source, java.lang.String id, java.lang.String stateId, java.util.Map parameters)
          Create a new event with the specified id occuring in the state with the specified stateId and the provided contextual parameters.
 
Method Summary
protected  void addParameters(java.util.Map parameters)
          Add given parameters to the set of parameters of this event.
 boolean containsAttribute(java.lang.String attributeName)
           
 java.lang.Object getAttribute(java.lang.String attributeName)
           
 java.lang.String getId()
          Returns the event identifier.
 java.lang.Object getParameter(java.lang.String parameterName)
          Returns a parameter value given a parameter name, or null if the parameter was not found.
 java.util.Map getParameters()
          Returns an unmodifiable parameter map storing parameters associated with this event.
 java.lang.String getStateId()
          Returns the state in which this event occured (optional).
 long getTimestamp()
          Returns the time at which the event occured.
protected  void setId(java.lang.String id)
          Set the event identifier.
protected  void setParameters(java.util.Map parameters)
          Set the contextual parameters.
protected  void setRequiredId(java.lang.String id)
          Set the event identifier and make sure it is not null.
protected  void setStateId(java.lang.String stateId)
          Set the state identifier.
 java.lang.String toString()
           
 
Methods inherited from class java.util.EventObject
getSource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Event

public Event(java.lang.Object source)
Constructs a new event with the specified source.

Parameters:
source - the source of the event

Event

public Event(java.lang.Object source,
             java.lang.String id)
Create a new event with the specified id.

Parameters:
source - the source of the event
id - the event identifier

Event

public Event(java.lang.Object source,
             java.lang.String id,
             java.util.Map parameters)
Create a new event with the specified id and the provided contextual parameters.

Parameters:
source - the source of the event
id - the event identifier
parameters - the event parameters

Event

public Event(java.lang.Object source,
             java.lang.String id,
             java.lang.String stateId,
             java.util.Map parameters)
Create a new event with the specified id occuring in the state with the specified stateId and the provided contextual parameters.

Parameters:
source - the source of the event
id - the event identifier
stateId - the state in which this event occured
parameters - contextual parameters
Method Detail

getId

public java.lang.String getId()
Returns the event identifier. This could be null if not available, e.g. for an event starting a flow.

Returns:
the event id

setRequiredId

protected void setRequiredId(java.lang.String id)
Set the event identifier and make sure it is not null.

Parameters:
id - the event identifier

setId

protected void setId(java.lang.String id)
Set the event identifier.


getTimestamp

public long getTimestamp()
Returns the time at which the event occured.

Returns:
the timestamp

getStateId

public java.lang.String getStateId()
Returns the state in which this event occured (optional).

Returns:
the state id, or null if not specified

setStateId

protected void setStateId(java.lang.String stateId)
Set the state identifier.


getParameter

public java.lang.Object getParameter(java.lang.String parameterName)
Returns a parameter value given a parameter name, or null if the parameter was not found.

Parameters:
parameterName - the name of the parameter
Returns:
the parameter value, or null if the parameter is not present in the event

getParameters

public java.util.Map getParameters()
Returns an unmodifiable parameter map storing parameters associated with this event.

Returns:
the parameters of the event

setParameters

protected void setParameters(java.util.Map parameters)
Set the contextual parameters.


addParameters

protected void addParameters(java.util.Map parameters)
Add given parameters to the set of parameters of this event.


containsAttribute

public boolean containsAttribute(java.lang.String attributeName)
Specified by:
containsAttribute in interface org.springframework.binding.AttributeSource

getAttribute

public java.lang.Object getAttribute(java.lang.String attributeName)
Specified by:
getAttribute in interface org.springframework.binding.AttributeSource

toString

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


Copyright © 2005. All Rights Reserved.