public class TextInterface extends ObservingAgentUI
Title: CASA Agent Infrastructure
Description:
Copyright: Copyright 2003-2014, Knowledge Science Group, University of Calgary. Permission to use, copy, modify, distribute and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. The Knowledge Science Group makes no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty.
Company: Knowledge Science Group, University of Calgary
Modifier and Type | Class and Description |
---|---|
class |
TextInterface.InputListener |
Modifier and Type | Field and Description |
---|---|
(package private) boolean |
exit |
protected String |
prompt |
(package private) Thread |
thread |
agent, showEvents, showInfo, showMessages, showTrace, showUnknown
TYPE_ANY, TYPE_BOOLEAN, TYPE_FLOAT, TYPE_INT, TYPE_STRING
Constructor and Description |
---|
TextInterface(TransientAgent a,
String[] args,
boolean useListener)
Create a new
AgentUI that reads from System.in and prints to System.out. |
TextInterface(TransientAgent a,
String[] args,
Thread thread)
Create a new
AgentUI that reads from System.in and prints to System.out. |
Modifier and Type | Method and Description |
---|---|
String |
ask(String prompt,
String help,
int type,
String _default)
The general contract is that the UI will return a string from the user
after prompting the use, that conforms to the the type specified by the
type parameter.
|
OutputStream |
getOutStream()
Returns an output stream that can be used to write to the interface
|
void |
print(String txt) |
void |
println(String txt) |
void |
start()
Doesn't do anything in text UI
|
boolean |
takesHTML() |
void |
update(Observable o,
Object arg)
Description: adapted from the previous update().
|
eval, evalWithHistory, handleEvent, handleOther, printlnObject
public TextInterface(TransientAgent a, String[] args, Thread thread)
AgentUI
that reads from System.in and prints to System.out.a
- The agent for which this interface is createdargs
- the arguments vector (as per the standard main(String[])) containing the command name and arguments to executethread
- sends an interrupt to this thread whenever an EOF character is encountered at the end of a print() call.public TextInterface(TransientAgent a, String[] args, boolean useListener)
AgentUI
that reads from System.in and prints to System.out.a
- The agent for which this interface is createdargs
- the arguments vector (as per the standard main(String[])) containing the command name and arguments to executeuseListener
- if true, creates a listener thread that prompts for new commands from System.inpublic void update(Observable o, Object arg)
Description: adapted from the previous update(). The structure and most comments
belong to the author of the previous version. Update() now uses ObserverNotification
update
in interface Observer
update
in class ObservingAgentUI
public boolean takesHTML()
public void print(String txt)
public void println(String txt)
public String ask(String prompt, String help, int type, String _default)
AgentUI
prompt
- The prompt the use will seehelp
- An extended prompt if the user enters something inappropriatetype
- The type which may be
Integer.parseInt(String)
Float.parseFloat(String)
_default
- The value to return (unchecked) if the user just hits [return]public void start()
public OutputStream getOutStream()
AgentUI