stella
Class ReplyEvent

java.lang.Object
  extended by java.util.EventObject
      extended by util.rmi.RmiEvent
          extended by stella.MessageEvent
              extended by stella.ReplyEvent
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
AcknowledgeEvent, DoneEvent

public abstract class ReplyEvent
extends MessageEvent

A intermediate class between the pure message event class and the acknowledge and done events. This class carries information of the command it follows within its command-time-tag and the command-type fields. This behaviour is reflected in the getExecuteGroupKey() method which returns equal objects when invoked on different messages belonging to one execution block. I.e. any command/acknowledge/done sequence will return the same key with this method call.

See Also:
Serialized Form

Field Summary
private  long commandTime
          The command time tag this acknowledge event follows.
private  String commandType
          The command type this acknowledge event follows.
static char VARSEP
          The seperator char for combining reply type and command type.
 
Fields inherited from class stella.MessageEvent
SEPCHAR
 
Fields inherited from class util.rmi.RmiEvent
localHost, sourceName
 
Fields inherited from class java.util.EventObject
source
 
Constructor Summary
protected ReplyEvent(Object src, String type, long time)
          Constructs a reply event as an answer for the given command.
 
Method Summary
static ReplyEvent createMatch(Object src, String type, long time, CommandEvent to)
          Creates a reply match.
static ReplyEvent createReply(MessageBin bin)
          Creates a non-abstract subclass of a reply event from a MessageBin object.
 boolean equals(Object that)
          Test additionally for equality of command type and command time progenitor equality.
 long getCommandTime()
          Returns the command time-tag of the progenitor command.
 String getCommandType()
          Returns the command type of the progenitor command.
 Object getExecuteGroupKey()
          Returns a simple key for comparison in a hash table.
protected  String getProgenitor()
          Returns the string representation of the progenitor command.
 String getReplyMatch()
          Returns the type of this reply and the type of the command in a single string.
 boolean matches(ReplyEvent that)
          Checks if this reply event matches the argument one.
protected  boolean parseProgenitor(String cl)
          Parses the command type and the command time of the progenitor command from a single String.
protected  void setCommandTime(long ctime)
          Sets the time-tag of the progenitor command.
protected  void setCommandType(String ctype)
          Sets the type of the progenitor command.
 
Methods inherited from class stella.MessageEvent
checkType, equalTime, equalTime, fromAscii, getAllCommandLines, getHead, getLine, getNr, getTime, getType, hashCode, isValid, parseFromSingleString, parseLine, readFromBufferedStream, setNr, setTime, setType, setValid, toString
 
Methods inherited from class util.rmi.RmiEvent
getHost, getSourceName, setSourceName
 
Methods inherited from class java.util.EventObject
getSource
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

VARSEP

public static final char VARSEP
The seperator char for combining reply type and command type. This char may not be a whitespace char.

See Also:
Constant Field Values

commandType

private String commandType
The command type this acknowledge event follows.


commandTime

private long commandTime
The command time tag this acknowledge event follows.

Constructor Detail

ReplyEvent

protected ReplyEvent(Object src,
                     String type,
                     long time)
Constructs a reply event as an answer for the given command.

Parameters:
src - The origin of the reply event.
type - The type of the reply event.
time - The time-tag of the reply event.
Method Detail

setCommandType

protected void setCommandType(String ctype)
Sets the type of the progenitor command.


setCommandTime

protected void setCommandTime(long ctime)
Sets the time-tag of the progenitor command.


createReply

public static ReplyEvent createReply(MessageBin bin)
Creates a non-abstract subclass of a reply event from a MessageBin object.


createMatch

public static ReplyEvent createMatch(Object src,
                                     String type,
                                     long time,
                                     CommandEvent to)
Creates a reply match. Used to generate reply templates that may be matched with true replies (done or acknowledge events) with the matches(stella.ReplyEvent) method.


parseProgenitor

protected boolean parseProgenitor(String cl)
Parses the command type and the command time of the progenitor command from a single String. The command type of the progenitor is the substring of the argument from index zero to the first index of MessageEvent.SEPCHAR. The command time is parsed from the long immediately following the separator char.

Returns:
True if parsing was successful

getProgenitor

protected String getProgenitor()
Returns the string representation of the progenitor command. Called by subclasses to construct the command line of the reply event.


getCommandType

public String getCommandType()
Returns the command type of the progenitor command.


getCommandTime

public long getCommandTime()
Returns the command time-tag of the progenitor command.


getReplyMatch

public String getReplyMatch()
Returns the type of this reply and the type of the command in a single string. This is used for reply matching to variables in a sequencer.


getExecuteGroupKey

public Object getExecuteGroupKey()
Returns a simple key for comparison in a hash table. This method wrapps the command type and the command time-tag into a single string. The intended use of this method is the matching of a command/acknowledge/done sequence into a single key.

Overrides:
getExecuteGroupKey in class MessageEvent

matches

public boolean matches(ReplyEvent that)
Checks if this reply event matches the argument one. Note that this method is not symmetric in the sense that jokers may only be used in the argument.
A match requires the following conditions to be met:


equals

public boolean equals(Object that)
Test additionally for equality of command type and command time progenitor equality.

Overrides:
equals in class MessageEvent
Parameters:
that - The Object to compare to.
Returns:
True, if both MessageEvents are equal.
See Also:
MessageEvent.equalTime(long)