janino.net

org.codehaus.janino
Class Scanner

  extended by org.codehaus.janino.Scanner

public class Scanner
extends

Splits up a character stream into tokens and returns them as objects.

The optionalFileName parameter passed to many constructors should point


Nested Class Summary
 class Scanner.Token
          Representation of a Java™ token.
 
Constructor Summary
Scanner( file)
          Deprecated. // SUPPRESS CHECKSTYLE MissingDeprecated
Scanner( file,  optionalEncoding)
          Deprecated. // SUPPRESS CHECKSTYLE MissingDeprecated
Scanner( fileName)
          Deprecated. // SUPPRESS CHECKSTYLE MissingDeprecated
Scanner( optionalFileName,  is)
          Set up a scanner that reads tokens from the given in the platform default encoding.
Scanner( optionalFileName,  is,  optionalEncoding)
          Set up a scanner that reads tokens from the given with the given optionalEncoding (null means platform default encoding).
Scanner( optionalFileName,  in)
          Set up a scanner that reads tokens from the given .
Scanner( optionalFileName,  in, short initialLineNumber, short initialColumnNumber)
          Creates a Scanner that counts lines and columns from non-default initial values.
Scanner( fileName,  encoding)
          Deprecated. // SUPPRESS CHECKSTYLE MissingDeprecated
 
Method Summary
 void close()
          Deprecated. This method is deprecated, because the concept described above is confusing. An application should close the underlying or itself.
  doc()
          Get the text of the doc comment (a.k.a.
 boolean getExpectGreater()
           
  getFileName()
           
 Location location()
           
 Scanner.Token produce()
          Preduces and returns the next token.
 boolean setExpectGreater(boolean value)
          Sets or resets the 'expect greater' mode.
 void setWarningHandler(WarningHandler optionalWarningHandler)
          By default, warnings are discarded, but an application my install a WarningHandler.
 
Methods inherited from class java.lang.
, , , , , , , , , ,
 

Constructor Detail

Scanner


public Scanner( fileName)
        throws CompileException,
               
Deprecated. // SUPPRESS CHECKSTYLE MissingDeprecated

Set up a scanner that reads tokens from the given file in the default charset.

This method is deprecated because it leaves the input file open.

Throws:
CompileException

Scanner


public Scanner( fileName,
                           encoding)
        throws CompileException,
               
Deprecated. // SUPPRESS CHECKSTYLE MissingDeprecated

Set up a scanner that reads tokens from the given file in the given encoding.

This method is deprecated because it leaves the input file open.

Throws:
CompileException

Scanner


public Scanner( file)
        throws CompileException,
               
Deprecated. // SUPPRESS CHECKSTYLE MissingDeprecated

Set up a scanner that reads tokens from the given file in the platform default encoding.

This method is deprecated because it leaves the input file open.

Throws:
CompileException

Scanner


public Scanner( file,
                           optionalEncoding)
        throws CompileException,
               
Deprecated. // SUPPRESS CHECKSTYLE MissingDeprecated

Set up a scanner that reads tokens from the given file in the given encoding.

This method is deprecated because it leaves the input file open.

Throws:
CompileException

Scanner

public Scanner( optionalFileName,
                is)
        throws CompileException,
               
Set up a scanner that reads tokens from the given in the platform default encoding.

The fileName is solely used for reporting in thrown exceptions.

Throws:
CompileException

Scanner

public Scanner( optionalFileName,
                is,
                optionalEncoding)
        throws CompileException,
               
Set up a scanner that reads tokens from the given with the given optionalEncoding (null means platform default encoding).

The optionalFileName is used for reporting errors during compilation and for source level debugging, and should name an existing file. If null is passed, and the system property org.codehaus.janino.source_debugging.enable is set to "true", then a temporary file in org.codehaus.janino.source_debugging.dir or the system's default temp dir is created in order to make the source code available to a debugger.

Throws:
CompileException

Scanner

public Scanner( optionalFileName,
                in)
        throws CompileException,
               
Set up a scanner that reads tokens from the given .

The optionalFileName is used for reporting errors during compilation and for source level debugging, and should name an existing file. If null is passed, and the system property org.codehaus.janino.source_debugging.enable is set to "true", then a temporary file in org.codehaus.janino.source_debugging.dir or the system's default temp dir is created in order to make the source code available to a debugger.

Throws:
CompileException

Scanner

public Scanner( optionalFileName,
                in,
               short initialLineNumber,
               short initialColumnNumber)
        throws CompileException,
               
Creates a Scanner that counts lines and columns from non-default initial values.

Throws:
CompileException
Method Detail

getFileName

public  getFileName()
Returns:
The file name optionally passed to the constructor

close


public void close()
           throws 
Deprecated. This method is deprecated, because the concept described above is confusing. An application should close the underlying or itself.

Closes the character source (file, , ) associated with this object. The results of future calls to produce() are undefined.

Throws:

doc

public  doc()
Get the text of the doc comment (a.k.a. "JAVADOC comment") preceeding the next token.

Returns:
null if the next token is not preceeded by a doc comment

location

public Location location()
Returns:
The Location of the next character

produce

public Scanner.Token produce()
                      throws CompileException,
                             
Preduces and returns the next token. Notice that end-of-input is not signalized with a null product, but by the special Scanner.Token.EOF token.

Throws:
CompileException

getExpectGreater

public boolean getExpectGreater()
Returns:
Whether the scanner is currently in 'expect greater' mode

setExpectGreater

public boolean setExpectGreater(boolean value)
Sets or resets the 'expect greater' mode.

Returns:
Whether the 'expect greater' mode was previously active

setWarningHandler

public void setWarningHandler(WarningHandler optionalWarningHandler)
By default, warnings are discarded, but an application my install a WarningHandler.

Notice that there is no Scanner.setErrorHandler() method, but scan errors always throw a CompileException. The reason being is that there is no reasonable way to recover from scan errors and continue scanning, so there is no need to install a custom scan error handler.

Parameters:
optionalWarningHandler - null to indicate that no warnings be issued

janino.net