unsw.cse.framescript
Class Domain

java.lang.Object
  extended by unsw.cse.framescript.Term
      extended by unsw.cse.framescript.Domain

public class Domain
extends Term

A domain is responsible for knowing the current state of a conversation. The domain knows what the topics are and what the current context is. When a user inputs an utterance it is given to a domain which is then responsible for determining the order of topics/contexts in which to try to find an appropriate response.

Author:
mmcgill

Method Summary
 boolean equals(Term t)
          Compares two Terms for equality.
 Term eval(Instance currentObject, StackFrame stackframe)
          Evaluates a Term.
 Conversation getActiveConversation()
          Gets the current active conversation.
 Pattern getResponse(Pattern input)
          Gets the response from the domain for a given user input.
 void gotoScript(Script script)
          Changes the current context to the given script.
 void gotoTopic(Script topic)
          Changes the topic to the given script and changes the current context.
 void registerTopic(Script topic)
          Registers a script as a topic for the domain.
 void setActiveConversation(Conversation conversation)
          Sets a conversation as being active with the domain.
 java.lang.String toString()
          Turns the Term into a string.
 
Methods inherited from class unsw.cse.framescript.Term
assign, asString, fullMatch, indents, mapVars, match
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

eval

public Term eval(Instance currentObject,
                 StackFrame stackframe)
          throws FSException
Description copied from class: Term
Evaluates a Term. For many Terms the result is to return itself.

Specified by:
eval in class Term
Parameters:
currentObject - the enclosing instance frame for the code being evaluated
stackframe - StackFrame that holds the values for any variables
Returns:
the result of the evaluation
Throws:
FSException - if any errors occur in performing the evaluation

equals

public boolean equals(Term t)
Description copied from class: Term
Compares two Terms for equality.

Specified by:
equals in class Term
Parameters:
t - Term to be compared to
Returns:
true if the Terms are equal, false otherwise

toString

public java.lang.String toString()
Description copied from class: Term
Turns the Term into a string.

Specified by:
toString in class Term

getResponse

public Pattern getResponse(Pattern input)
                    throws FSException
Gets the response from the domain for a given user input.

Parameters:
input - the input to respond to
Returns:
the response to the input
Throws:
FSException - if there is any error responding to the input

registerTopic

public void registerTopic(Script topic)
Registers a script as a topic for the domain.

Parameters:
topic - the script registering as a topic

gotoScript

public void gotoScript(Script script)
                throws FSException
Changes the current context to the given script. Runs any required daemons.

Parameters:
script - the script that is to become the current context
Throws:
FSException - any errors running daemons

gotoTopic

public void gotoTopic(Script topic)
               throws FSException
Changes the topic to the given script and changes the current context.

Parameters:
topic - the script to become the current topic and current context
Throws:
FSException - any errors in any daemons

getActiveConversation

public Conversation getActiveConversation()
Gets the current active conversation.

Returns:
the current active conversation, null if no conversation has been set as active

setActiveConversation

public void setActiveConversation(Conversation conversation)
Sets a conversation as being active with the domain.

Parameters:
conversation - the conversation that is being activated