com.cburch.editor
Interface Scanner<T>

Type Parameters:
T - The type of token this scanner is to read.
All Known Implementing Classes:
HtmlScanner, JavaScanner

public interface Scanner<T>

The interface that any scanner associated with an editor should implement.

Version:
0.1 2005-05-31
Author:
Carl Burch

Method Summary
 T nextToken()
          Returns the next token found on the input stream, or null if there are no more tokens left.
 void reset(java.io.Reader reader)
          Closes the current input stream, and resets the scanner to read from a new input stream.
 void reset(java.io.Reader reader, T token)
          Resets the scanner to its state just after reading the given token from the given reader.
 

Method Detail

reset

void reset(java.io.Reader reader,
           T token)
           throws java.io.IOException
Resets the scanner to its state just after reading the given token from the given reader. Normally, an implementation would just use the token's getEndOffset method to reset the current position; but depending on the scanner, the token may hold other state to restore also.

Parameters:
reader - the new input.
token - the token after which we will start.
Throws:
java.io.IOException - if an IOException occurs while switching readers.

reset

void reset(java.io.Reader reader)
           throws java.io.IOException
Closes the current input stream, and resets the scanner to read from a new input stream. All internal variables are reset; the old input stream cannot be reused. (The content of the internal buffer is discarded and lost.) The lexical state is set to the initial state.

Parameters:
reader - The new input.
Throws:
java.io.IOException - if an IOExecption occurs while switching readers.

nextToken

T nextToken()
            throws java.io.IOException
Returns the next token found on the input stream, or null if there are no more tokens left.

Returns:
the next token found on the input stream.
Throws:
java.io.IOException - if the underlying Reader throws it during the process.