mstar
Class Responder

java.lang.Object
  |
  +--mstar.Responder
Direct Known Subclasses:
ArrivalResponder, defaultResponder, DirectionsResponder, FetchURLResponder, FollowDirectionsResponder, GoResponder, GoToResponder, HelpResponder, RobotInformationResponder, RoomInformationResponder, SetResponder, ThreeLawsResponder, TimeResponder, WhatsNewResponder, WhereAreYouResponder

public abstract class Responder
extends java.lang.Object

A class that emits responses from the robot to other players in the collaborative environment.

Version:
1.6
Author:
Thaddeus O. Cooper

Constructor Summary
Responder()
          Creates an empty responder.
Responder(java.lang.String name)
          Creates a responder and sets the name of the robot to the specified name.
Responder(java.lang.String name, MudMap map)
          Creates a responder and sets the name of the robot to the specified name, and the map to the specified MudMap.
Responder(java.lang.String name, MudMap map, java.lang.String who)
          Creates a responder and sets the name of the robot to the specified name, the map to the specified MudMap, and who to the name of the character that the robot is responding to.
Responder(java.lang.String name, MudMap map, java.lang.String who, java.lang.String what)
          Creates a responder and sets the name of the robot to the specified name, the map to the specified MudMap, who to the name of the character that the robot is responding to, and what the character said to the robot.
Responder(java.lang.String name, MudMap map, java.lang.String who, java.lang.String what, java.io.DataInputStream in)
          Creates a responder and sets the name of the robot to the specified name, the map to the specified MudMap, who to the name of the character that the robot is responding to, what the character said to the robot, and the input stream that the robot can listen to the collaborative environment on.
Responder(java.lang.String name, MudMap map, java.lang.String who, java.lang.String what, java.io.DataInputStream in, java.io.PrintStream out)
          Creates a responder and sets the name of the robot to the specified name, the map to the specified MudMap, who to the name of the character that the robot is responding to, what the character said to the robot, the input stream that the robot can listen to the collaborative environment on, and the output stream that the robot can write to the collaborative environment on.
Responder(java.lang.String name, MudMap map, java.lang.String who, java.lang.String what, java.io.DataInputStream in, java.io.PrintStream out, java.util.Properties properties)
          Creates a responder and sets the name of the robot to the specified name, the map to the specified MudMap, who to the name of the character that the robot is responding to, what the character said to the robot, the input stream that the robot can listen to the collaborative environment on, the output stream that the robot can write to the collaborative environment on, and the properties that were set for the robot when it started.
 
Method Summary
 void addAction(java.lang.String how, java.lang.String action)
          Adds an action, pose, emote, etc.
 void addResponse(java.lang.String response)
          Adds a spoken response.
protected  void addRobotAction(java.lang.String action, java.lang.String response)
          Adds an action, pose, emote, etc.
abstract  boolean canProcess(Chatter c)
          Determines if this responder will respond to the data contained in the chatter.
 java.lang.String getAction()
          Gets the robot's action.
 RobotAction[] getActions()
          Gets the list of actions that the robot is supposed to perform.
 Commands getCommands()
          Gets the commands for this collaborative environment.
 Connection getConnection()
          Gets the connection for this collaborative environment.
 java.lang.String getHow()
          Gets how the person interacted with the robot.
 java.io.DataInputStream getInputStream()
          Gets the input stream to listen to the collaborative environment on.
 MudMap getMap()
          Gets the map of the mud.
 java.io.PrintStream getOutputStream()
          Gets the output stream to write to the collaborative environment on.
 java.lang.String getOwner()
          Gets the name of the owner of this robot.
 PlayerMap getPlayerMap()
          Gets the current players map to the specified map.
 ProcessTable getProcessTable()
          Deprecated.  
 java.util.Properties getProperties()
          Gets the properties from when the robot was started.
 java.lang.String getResponse()
          Gets the robot's response.
 java.lang.String getRobotName()
          Gets the name of the robot.
 ParseRoomDescription getRoomParser()
          Sets the room parser.
 java.util.Vector getShared()
          Gets the shared data space.
 int getState()
          Gets the state of the responder.
 java.lang.String getWhat()
          Gets what the person said to the robot.
 java.lang.String getWho()
          Gets who is talking to the robot.
abstract  void process()
          Actually process the input from the collaborative environment and add the actions and responses to the Vector to be output when this routine returns.
abstract  java.lang.String serviceType()
          Returns a string the defines the type of service that this responder provides.
 void setAction(java.lang.String action)
          Sets the robot's action.
 void setCommands(Commands commands)
          Sets the commands for this collaborative environment.
 void setConnection(Connection connection)
          Sets the connection for this collaborative environment.
 void setHow(java.lang.String how)
          Sets how the person interacted with the robot.
 void setInputStream(java.io.DataInputStream in)
          Sets the input stream to listen to the collaborative environment on.
 void setMap(MudMap map)
          Sets the map of the mud.
 void setOutputStream(java.io.PrintStream out)
          Sets the output stream to write to the collaborative environment on.
 void setOwner(java.lang.String owner)
          Sets the name of the owner of this robot.
 void setPlayerMap(PlayerMap players)
          Sets the current players map to the specified map.
 void setProcessTable(ProcessTable processTable)
          Deprecated.  
 void setProperties(java.util.Properties properties)
          Sets the properties from when the robot was started.
protected  void setResponse(java.lang.String response)
          Sets the robot's response.
 void setRobotName(java.lang.String name)
          Sets the name of the robot.
 void setRoomParser(ParseRoomDescription roomParser)
          Sets the room parser.
 void setShared(java.util.Vector shared)
          Sets the shared data space.
 void setState(int state)
          Sets the state of the responder.
 void setWhat(java.lang.String what)
          Sets what the person said to the robot.
 void setWho(java.lang.String who)
          Sets who is talking to the robot.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Responder

public Responder()
Creates an empty responder.

Responder

public Responder(java.lang.String name)
Creates a responder and sets the name of the robot to the specified name.
Parameters:
name - The name of the robot.

Responder

public Responder(java.lang.String name,
                 MudMap map)
Creates a responder and sets the name of the robot to the specified name, and the map to the specified MudMap.
Parameters:
name - The name of the robot.
map - The map of the mud that the robot has constructed.

Responder

public Responder(java.lang.String name,
                 MudMap map,
                 java.lang.String who)
Creates a responder and sets the name of the robot to the specified name, the map to the specified MudMap, and who to the name of the character that the robot is responding to.
Parameters:
name - The name of the robot.
map - The map of the mud that the robot has constructed.
who - The name of the character that the robot is responding to.

Responder

public Responder(java.lang.String name,
                 MudMap map,
                 java.lang.String who,
                 java.lang.String what)
Creates a responder and sets the name of the robot to the specified name, the map to the specified MudMap, who to the name of the character that the robot is responding to, and what the character said to the robot.
Parameters:
name - The name of the robot.
map - The map of the mud that the robot has constructed.
who - The name of the character that the robot is responding to.
what - What the character said to the robot.

Responder

public Responder(java.lang.String name,
                 MudMap map,
                 java.lang.String who,
                 java.lang.String what,
                 java.io.DataInputStream in)
Creates a responder and sets the name of the robot to the specified name, the map to the specified MudMap, who to the name of the character that the robot is responding to, what the character said to the robot, and the input stream that the robot can listen to the collaborative environment on.
Parameters:
name - The name of the robot.
map - The map of the mud that the robot has constructed.
who - The name of the character that the robot is responding to.
what - What the character said to the robot.
in - The input stream that the robot can listen to the environment on.

Responder

public Responder(java.lang.String name,
                 MudMap map,
                 java.lang.String who,
                 java.lang.String what,
                 java.io.DataInputStream in,
                 java.io.PrintStream out)
Creates a responder and sets the name of the robot to the specified name, the map to the specified MudMap, who to the name of the character that the robot is responding to, what the character said to the robot, the input stream that the robot can listen to the collaborative environment on, and the output stream that the robot can write to the collaborative environment on.
Parameters:
name - The name of the robot.
map - The map of the mud that the robot has constructed.
who - The name of the character that the robot is responding to.
what - What the character said to the robot.
in - The input stream that the robot can listen to the environment on.
out - The output stream that the robot can output to.

Responder

public Responder(java.lang.String name,
                 MudMap map,
                 java.lang.String who,
                 java.lang.String what,
                 java.io.DataInputStream in,
                 java.io.PrintStream out,
                 java.util.Properties properties)
Creates a responder and sets the name of the robot to the specified name, the map to the specified MudMap, who to the name of the character that the robot is responding to, what the character said to the robot, the input stream that the robot can listen to the collaborative environment on, the output stream that the robot can write to the collaborative environment on, and the properties that were set for the robot when it started.
Parameters:
name - The name of the robot.
map - The map of the mud that the robot has constructed.
who - The name of the character that the robot is responding to.
what - What the character said to the robot.
in - The input stream that the robot can listen to the environment on.
out - The output stream that the robot can output to.
properties - The properties that the robot was started with.
Method Detail

setRobotName

public void setRobotName(java.lang.String name)
Sets the name of the robot.
Parameters:
name - The name of the robot.

getRobotName

public java.lang.String getRobotName()
Gets the name of the robot.
Returns:
The name of the robot.

setMap

public void setMap(MudMap map)
Sets the map of the mud.
Parameters:
map - The map of the mud that the robot has constructed.

getMap

public MudMap getMap()
Gets the map of the mud.
Returns:
The map of the mud that the robot has constructed.

setWho

public void setWho(java.lang.String who)
Sets who is talking to the robot.
Parameters:
who - The name of the character that the robot is responding to.

getWho

public java.lang.String getWho()
Gets who is talking to the robot.
Returns:
The name of the character that the robot is responding to.

setWhat

public void setWhat(java.lang.String what)
Sets what the person said to the robot.
Parameters:
what - What the character said to the robot.

getWhat

public java.lang.String getWhat()
Gets what the person said to the robot.
Returns:
What the character said to the robot.

setHow

public void setHow(java.lang.String how)
Sets how the person interacted with the robot. For example, did they say it, page it, whisper to it.
Parameters:
how - they interacted with the robot.

getHow

public java.lang.String getHow()
Gets how the person interacted with the robot. For example, did they say it, page it, whisper to it.
Returns:
how they interacted with the robot.

setResponse

protected void setResponse(java.lang.String response)
Sets the robot's response.
Parameters:
response - the response from the robot.

getResponse

public java.lang.String getResponse()
Gets the robot's response.
Returns:
the response from the robot.

setAction

public void setAction(java.lang.String action)
Sets the robot's action.
Parameters:
action - the robot's action.

getAction

public java.lang.String getAction()
Gets the robot's action.
Returns:
the robot's action.

setProperties

public void setProperties(java.util.Properties properties)
Sets the properties from when the robot was started.
Parameters:
properties - the robot's properties from when it was started.

getProperties

public java.util.Properties getProperties()
Gets the properties from when the robot was started.
Returns:
the robot's properties from when it was started.

setInputStream

public void setInputStream(java.io.DataInputStream in)
Sets the input stream to listen to the collaborative environment on.
Parameters:
in - the stream to listen to the collaborative environment on.

getInputStream

public java.io.DataInputStream getInputStream()
Gets the input stream to listen to the collaborative environment on.
Returns:
the stream to listen to the collaborative environment on.

setOutputStream

public void setOutputStream(java.io.PrintStream out)
Sets the output stream to write to the collaborative environment on.
Parameters:
out - the stream to write to the collaborative environment on.

getOutputStream

public java.io.PrintStream getOutputStream()
Gets the output stream to write to the collaborative environment on.
Returns:
the stream to write to the collaborative environment on.

setPlayerMap

public void setPlayerMap(PlayerMap players)
Sets the current players map to the specified map.
Parameters:
players - the players map.

getPlayerMap

public PlayerMap getPlayerMap()
Gets the current players map to the specified map.
Returns:
the players map.

setRoomParser

public void setRoomParser(ParseRoomDescription roomParser)
Sets the room parser.
Parameters:
roomParser - the parser for parsing room descriptions.

getRoomParser

public ParseRoomDescription getRoomParser()
Sets the room parser.
Returns:
the parser for parsing room descriptions.

setConnection

public void setConnection(Connection connection)
Sets the connection for this collaborative environment.
Parameters:
connection - the connection for this collaborative environment.

getConnection

public Connection getConnection()
Gets the connection for this collaborative environment.
Returns:
the connection for this collaborative environment.

setCommands

public void setCommands(Commands commands)
Sets the commands for this collaborative environment.
Parameters:
commands - the commands for this collaborative environment.

getCommands

public Commands getCommands()
Gets the commands for this collaborative environment.
Returns:
the commands for this collaborative environment.

setOwner

public void setOwner(java.lang.String owner)
Sets the name of the owner of this robot.
Parameters:
owner - the name of the owner of this robot.

getOwner

public java.lang.String getOwner()
Gets the name of the owner of this robot.
Returns:
the name of the owner of this robot.

setProcessTable

public void setProcessTable(ProcessTable processTable)
Deprecated.  


getProcessTable

public ProcessTable getProcessTable()
Deprecated.  


addRobotAction

protected void addRobotAction(java.lang.String action,
                              java.lang.String response)
Adds an action, pose, emote, etc. to the actions vector.
Parameters:
action - the type of action to perform.
response - the action to perform.

addResponse

public void addResponse(java.lang.String response)
Adds a spoken response. DEFAULT indicates that the object that is using this response class should apply the appropriate type of response based on the original interacton with the robot.
Parameters:
response - the response that the robot should say to the player that it is interacting with.

addAction

public void addAction(java.lang.String how,
                      java.lang.String action)
Adds an action, pose, emote, etc. to be performed.
Parameters:
how - the type of action to perform.
action - the action to perform.

getActions

public RobotAction[] getActions()
Gets the list of actions that the robot is supposed to perform.
Returns:
a RobotAction array with a list of all the actions that the robot is to perform.

setState

public void setState(int state)
Sets the state of the responder. Used for stateful responses.
Parameters:
state - the state the responder is in.

getState

public int getState()
Gets the state of the responder. Used for stateful responses.
Returns:
the state the responder is in.

setShared

public void setShared(java.util.Vector shared)
Sets the shared data space. The shared data space is the inter- process communication mechanism that is used by the robot for sharing information within itself.
Parameters:
shared - the vector of shared information.

getShared

public java.util.Vector getShared()
Gets the shared data space. The shared data space is the inter- process communication mechanism that is used by the robot for sharing information within itself.
Returns:
the vector of shared information.

process

public abstract void process()
Actually process the input from the collaborative environment and add the actions and responses to the Vector to be output when this routine returns.

serviceType

public abstract java.lang.String serviceType()
Returns a string the defines the type of service that this responder provides. Some examples include: NEWS, DIRECTIONS, and DEFAULT.
Returns:
the String that defines the type of service.

canProcess

public abstract boolean canProcess(Chatter c)
Determines if this responder will respond to the data contained in the chatter. If the chatter is able to be processed by this responder, then it should return true, if not it should return false.
Returns:
true if this reponder can process the input, false otherwise.