scanner
Class Scanner

java.lang.Object
  extended byscanner.Scanner

public class Scanner
extends java.lang.Object

A scanner is able to separate tokens from an input stream, following states defined in a finale state automata.


Constructor Summary
Scanner()
          Creates a new scanner.
Scanner(java.io.Reader stream)
          Creates a new scanner to scan the specified stream
Scanner(java.lang.String charStreamValue)
          Creates a new scanner to scan the specified string.
 
Method Summary
 void addListener(ScannerListenerInterface listener)
          Adds a listener to this scanner.
 java.lang.String getCurrentLine()
           
 FinaleStateAutomata getFinaleStateAutomata()
          Returns the current finale state automata currently used to separate tokens.
 CharStreamPosition getPosition()
          Returns the position of the scanner if the input stream.
 boolean hasNext()
          Returns true if there's any character left.
 void init(java.io.Reader readerStream)
          Inits this scanner to be able to perform a scan on the given stream
 void init(java.lang.String charStreamValue)
          Inits this scanner to be able to perform a scan on the given string
 Token nextToken()
          Returns the next token encountered.
 void removeListener(ScannerListenerInterface listener)
          Removes a listener from this scanner.
 void setFinaleStateAutomata(FinaleStateAutomata fsa)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Scanner

public Scanner(java.lang.String charStreamValue)
Creates a new scanner to scan the specified string.

Parameters:
charStreamValue - A string to be scanned.

Scanner

public Scanner(java.io.Reader stream)
Creates a new scanner to scan the specified stream

Parameters:
stream - The stream to be scanned.

Scanner

public Scanner()
Creates a new scanner.

Method Detail

init

public void init(java.lang.String charStreamValue)
Inits this scanner to be able to perform a scan on the given string

Parameters:
charStreamValue - A string to be scanned.

init

public void init(java.io.Reader readerStream)
Inits this scanner to be able to perform a scan on the given stream

Parameters:
readerStream - The stream to be scanned.

addListener

public void addListener(ScannerListenerInterface listener)
Adds a listener to this scanner.

Parameters:
listener - The listener to be added to this scanner.

removeListener

public void removeListener(ScannerListenerInterface listener)
Removes a listener from this scanner.

Parameters:
listener - The listener to be removed from this scanner.

nextToken

public Token nextToken()
                throws NoSuchTokenException
Returns the next token encountered.

Returns:
The next token encountered.
Throws:
Thrown - if there's no next valid token.
NoSuchTokenException

hasNext

public boolean hasNext()
Returns true if there's any character left.

Returns:
true if there's any character left, false otherwise.

getFinaleStateAutomata

public FinaleStateAutomata getFinaleStateAutomata()
Returns the current finale state automata currently used to separate tokens.

Returns:
the current finale state automata currently used to separate tokens.

setFinaleStateAutomata

public void setFinaleStateAutomata(FinaleStateAutomata fsa)

getPosition

public CharStreamPosition getPosition()
Returns the position of the scanner if the input stream.

Returns:
The position of the scanner if the input stream. The last processed character position.

getCurrentLine

public java.lang.String getCurrentLine()