org.jwalk
Class Console

java.lang.Object
  extended by org.jwalk.Console
All Implemented Interfaces:
java.util.EventListener, QuestionListener, ReportListener

public class Console
extends java.lang.Object
implements QuestionListener, ReportListener

Console provides a default channel for communication via the command line. A Console is installed as the default QuestionListener and ReportListener when Channels are created. This accepts QuestionEvents and ReportEvents, publishing Reports on standard output and responding to Questions on standard input. To respond to a Confirmation, the tester need only type "y", "n" or "q" (in either case) followed by carriage return to denote YES, NO or QUIT (aborts the current cycle). Typing carriage return is also considered short-hand for YES. To respond to a Notification, the tester need only type "y" or carriage return.

Version:
1.0
Author:
Anthony Simons

Constructor Summary
Console()
          Constructs a standard input output Console channel.
 
Method Summary
 void publish(ReportEvent event)
          Publishes the Report contained in the ReportEvent.
 Answer respond(QuestionEvent event)
          Responds to a question contained in the QuestionEvent.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Console

public Console()
Constructs a standard input output Console channel.

Method Detail

publish

public void publish(ReportEvent event)
Publishes the Report contained in the ReportEvent. The Report is extracted from the ReportEvent and is printed on standard output. No special processing is required for each type of Report, which is formatted using the default toString() method. No further indentation or line spaces are added.

Specified by:
publish in interface ReportListener
Parameters:
event - the ReportEvent that was dispatched.

respond

public Answer respond(QuestionEvent event)
Responds to a question contained in the QuestionEvent. The Question is extracted from the QuestionEvent and is printed on standard output. A response is solicited from the user on standard input, until a desired response is obtained.

Specified by:
respond in interface QuestionListener
Parameters:
event - the QuestionEvent dispatched by a JWalker.
Returns:
an Answer from {YES, NO, QUIT}.