Class Scanner
- java.lang.Object
-
- org.codehaus.janino.Scanner
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classScanner.TokenRepresentation of a Java™ token.
-
Constructor Summary
Constructors Constructor Description Scanner(File file)Deprecated.// SUPPRESS CHECKSTYLE MissingDeprecatedScanner(File file, String optionalEncoding)Deprecated.// SUPPRESS CHECKSTYLE MissingDeprecatedScanner(String fileName)Deprecated.// SUPPRESS CHECKSTYLE MissingDeprecatedScanner(String optionalFileName, InputStream is)Set up a scanner that reads tokens from the givenInputStreamin the platform default encoding.Scanner(String optionalFileName, InputStream is, String optionalEncoding)Set up a scanner that reads tokens from the givenInputStreamwith the givenoptionalEncoding(nullmeans platform default encoding).Scanner(String optionalFileName, Reader in)Set up a scanner that reads tokens from the givenReader.Scanner(String optionalFileName, Reader in, short initialLineNumber, short initialColumnNumber)Creates aScannerthat counts lines and columns from non-default initial values.Scanner(String fileName, String encoding)Deprecated.// SUPPRESS CHECKSTYLE MissingDeprecated
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidclose()Deprecated.This method is deprecated, because the concept described above is confusing.Stringdoc()Get the text of the doc comment (a.k.a.booleangetExpectGreater()StringgetFileName()Locationlocation()Scanner.Tokenproduce()Preduces and returns the next token.booleansetExpectGreater(boolean value)Sets or resets the 'expect greater' mode.voidsetWarningHandler(WarningHandler optionalWarningHandler)By default, warnings are discarded, but an application my install aWarningHandler.
-
-
-
Constructor Detail
-
Scanner
@Deprecated public Scanner(String fileName) throws CompileException, IOException
Deprecated.// SUPPRESS CHECKSTYLE MissingDeprecatedSet 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:
CompileExceptionIOException
-
Scanner
@Deprecated public Scanner(String fileName, String encoding) throws CompileException, IOException
Deprecated.// SUPPRESS CHECKSTYLE MissingDeprecatedSet 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:
CompileExceptionIOException
-
Scanner
@Deprecated public Scanner(File file) throws CompileException, IOException
Deprecated.// SUPPRESS CHECKSTYLE MissingDeprecatedSet 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:
CompileExceptionIOException
-
Scanner
@Deprecated public Scanner(File file, String optionalEncoding) throws CompileException, IOException
Deprecated.// SUPPRESS CHECKSTYLE MissingDeprecatedSet 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:
CompileExceptionIOException
-
Scanner
public Scanner(String optionalFileName, InputStream is) throws CompileException, IOException
Set up a scanner that reads tokens from the givenInputStreamin the platform default encoding.The
fileNameis solely used for reporting in thrown exceptions.- Throws:
CompileExceptionIOException
-
Scanner
public Scanner(String optionalFileName, InputStream is, String optionalEncoding) throws CompileException, IOException
Set up a scanner that reads tokens from the givenInputStreamwith the givenoptionalEncoding(nullmeans platform default encoding).The
optionalFileNameis used for reporting errors during compilation and for source level debugging, and should name an existing file. Ifnullis passed, and the system propertyorg.codehaus.janino.source_debugging.enableis set to "true", then a temporary file inorg.codehaus.janino.source_debugging.diror the system's default temp dir is created in order to make the source code available to a debugger.- Throws:
CompileExceptionIOException
-
Scanner
public Scanner(String optionalFileName, Reader in) throws CompileException, IOException
Set up a scanner that reads tokens from the givenReader.The
optionalFileNameis used for reporting errors during compilation and for source level debugging, and should name an existing file. Ifnullis passed, and the system propertyorg.codehaus.janino.source_debugging.enableis set to "true", then a temporary file inorg.codehaus.janino.source_debugging.diror the system's default temp dir is created in order to make the source code available to a debugger.- Throws:
CompileExceptionIOException
-
Scanner
public Scanner(String optionalFileName, Reader in, short initialLineNumber, short initialColumnNumber) throws CompileException, IOException
Creates aScannerthat counts lines and columns from non-default initial values.- Throws:
CompileExceptionIOException
-
-
Method Detail
-
getFileName
public String getFileName()
- Returns:
- The file name optionally passed to the constructor
-
close
@Deprecated public void close() throws IOException
Deprecated.This method is deprecated, because the concept described above is confusing. An application should close the underlyingInputStreamorReaderitself.Closes the character source (file,InputStream,Reader) associated with this object. The results of future calls toproduce()are undefined.- Throws:
IOException
-
doc
public String doc()
Get the text of the doc comment (a.k.a. "JAVADOC comment") preceeding the next token.- Returns:
nullif the next token is not preceeded by a doc comment
-
produce
public Scanner.Token produce() throws CompileException, IOException
Preduces and returns the next token. Notice that end-of-input is not signalized with anullproduct, but by the specialScanner.Token.EOFtoken.- Throws:
CompileExceptionIOException
-
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 aWarningHandler.Notice that there is no
Scanner.setErrorHandler()method, but scan errors always throw aCompileException. 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-nullto indicate that no warnings be issued
-
-