com.agentfactory.platform.util
Class Scanner

java.lang.Object
  extended by com.agentfactory.platform.util.Scanner

public class Scanner
extends java.lang.Object

This class provides support for parsing of textual content. It breaks the text up in to a set of statements that are delimited by a carriage return, such as: COMMAND arg1 arg2 ... TO DO (Rem Collier): Implement support for multi-line statements that take the form: COMMAND { arg1 arg2 } NOTE: In this revised format, each argument in the statement will be delimited based only on the end of line character. Finally, the scanner is designed to ignore both single line and multi line comments (based on Java style syntax).


Constructor Summary
Scanner(java.io.InputStream in)
          Create a scanner based on an input stream by wrapping the InputStream object in an InputStreamReader.
Scanner(java.io.Reader in)
          Create a scanner based a Reader object.
Scanner(java.lang.String text)
          Create a scanner based on some text by wrapping the text in a StringReader.
 
Method Summary
 void close()
          close the underlying BufferedReader
 boolean hasNext()
          Checks whether or not the scanner has any more statements
 java.util.List nextStatement()
          This method reads from the BufferedReader, character by character, generating a list of tokens that represent a single statement from the file (based on the syntax requirements laid down in the class comment).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Scanner

public Scanner(java.io.InputStream in)
Create a scanner based on an input stream by wrapping the InputStream object in an InputStreamReader.

Parameters:
in - the InputStream object.

Scanner

public Scanner(java.lang.String text)
Create a scanner based on some text by wrapping the text in a StringReader.

Parameters:
text - the text that the scanner is to scan.

Scanner

public Scanner(java.io.Reader in)
Create a scanner based a Reader object. This constructor is invoked by all other class constructors and wraps the Reader object in a BufferedReader.

Parameters:
in - the Reader object whose output is to be scanned.
Method Detail

nextStatement

public java.util.List nextStatement()
                             throws java.io.IOException
This method reads from the BufferedReader, character by character, generating a list of tokens that represent a single statement from the file (based on the syntax requirements laid down in the class comment).

Returns:
Returns a list of strings that represent a single statement from the file.
Throws:
java.io.IOException

hasNext

public boolean hasNext()
Checks whether or not the scanner has any more statements

Returns:
true if the scanner is not finished, false otherwise

close

public void close()
close the underlying BufferedReader