it.amattioli.workstate.core
Class Event

Show UML class diagram
java.lang.Object
  extended by it.amattioli.workstate.core.Event
All Implemented Interfaces:
AttributeReader

public class Event
extends Object
implements AttributeReader

Represents an event that can be received by a state machine. An event is identified by its MetaEvent and by its actual parameters. The actual parameters values must be compatible with the formal parameters defined in the MetaEvent.


Field Summary
static Event NULL
          This constant is a null event.
 
Constructor Summary
Event(MetaEvent metaEvent, Map<String,Object> parameters)
          Construct a new event given its MetaEvent and its actual parameters.
 
Method Summary
 Map<String,Object> getAllAttributes()
           
 Object getAttribute(String tag)
          Return the event parameter value whose tag is the passed string.
 Object getParameter(String tag)
          Return the event parameter value whose tag is the passed string.
 boolean hasMetaEvent(MetaEvent metaEvent)
          Verifies if this event is associated with a given MetaEvent.
 boolean isAllowedParameter(String tag)
           
 String toString()
          Return the string representation of this event.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NULL

public static final Event NULL
This constant is a null event. It can be used as a Null Object.

Constructor Detail

Event

public Event(MetaEvent metaEvent,
             Map<String,Object> parameters)
Construct a new event given its MetaEvent and its actual parameters. In the parameters map the keys are the parameter names as defined in the MetaEvent while the values are the parameters values.

No check on parameters is performed by this constructor. The caller must ensure that the parameters are valid and compatible with the formal parameters defined in the MetaEvent.

Method Detail

hasMetaEvent

public boolean hasMetaEvent(MetaEvent metaEvent)
Verifies if this event is associated with a given MetaEvent.

Parameters:
metaEvent - the MetaEvent
Returns:
true if the parameter is the MetaEvent associted to this event, false otherwise

isAllowedParameter

public boolean isAllowedParameter(String tag)

getParameter

public Object getParameter(String tag)
Return the event parameter value whose tag is the passed string.

Parameters:
tag - the tag of the parameter
Returns:
the parameter value
Throws:
IllegalArgumentException - if this event has no parameter with the given tag

getAttribute

public Object getAttribute(String tag)
Return the event parameter value whose tag is the passed string.

Specified by:
getAttribute in interface AttributeReader

getAllAttributes

public Map<String,Object> getAllAttributes()
Specified by:
getAllAttributes in interface AttributeReader

toString

public String toString()
Return the string representation of this event. This representation will be the event tag followed by its parameters. Every parameter will be "tag = value".

Overrides:
toString in class Object
Returns:
the string representation of this event.


Copyright © 2011. All Rights Reserved.