Class Scanner
- java.lang.Object
-
- org.codehaus.janino.Scanner
-
public class Scanner extends java.lang.ObjectSplits up a character stream into tokens and returns them asStringobjects.The
optionalFileNameparameter passed to many constructors should point
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classScanner.Token
-
Constructor Summary
Constructors Constructor Description Scanner(java.io.File file)Deprecated.Scanner(java.io.File file, java.lang.String optionalEncoding)Deprecated.Scanner(java.lang.String fileName)Deprecated.Scanner(java.lang.String optionalFileName, java.io.InputStream is)Set up a scanner that reads tokens from the givenInputStreamin the platform default encoding.Scanner(java.lang.String optionalFileName, java.io.InputStream is, java.lang.String optionalEncoding)Set up a scanner that reads tokens from the givenInputStreamwith the givenoptionalEncoding(nullmeans platform default encoding).Scanner(java.lang.String optionalFileName, java.io.Reader in)Set up a scanner that reads tokens from the givenReader.Scanner(java.lang.String optionalFileName, java.io.Reader in, short initialLineNumber, short initialColumnNumber)Creates aScannerthat counts lines and columns from non-default initial values.Scanner(java.lang.String fileName, java.lang.String encoding)Deprecated.
-
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.java.lang.Stringdoc()Get the text of the doc comment (a.k.a.java.lang.StringgetFileName()Return the file name optionally passed to the constructor.Locationlocation()Returns theLocationof the next character.Scanner.Tokenproduce()voidsetWarningHandler(WarningHandler optionalWarningHandler)By default, warnings are discarded, but an application my install aWarningHandler.
-
-
-
Constructor Detail
-
Scanner
@Deprecated public Scanner(java.lang.String fileName) throws CompileException, java.io.IOExceptionDeprecated.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:
CompileExceptionjava.io.IOException
-
Scanner
@Deprecated public Scanner(java.lang.String fileName, java.lang.String encoding) throws CompileException, java.io.IOExceptionDeprecated.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:
CompileExceptionjava.io.IOException
-
Scanner
@Deprecated public Scanner(java.io.File file) throws CompileException, java.io.IOExceptionDeprecated.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:
CompileExceptionjava.io.IOException
-
Scanner
@Deprecated public Scanner(java.io.File file, java.lang.String optionalEncoding) throws CompileException, java.io.IOExceptionDeprecated.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:
CompileExceptionjava.io.IOException
-
Scanner
public Scanner(java.lang.String optionalFileName, java.io.InputStream is) throws CompileException, java.io.IOExceptionSet up a scanner that reads tokens from the givenInputStreamin the platform default encoding.The
fileNameis solely used for reporting in thrown exceptions.- Throws:
CompileExceptionjava.io.IOException
-
Scanner
public Scanner(java.lang.String optionalFileName, java.io.InputStream is, java.lang.String optionalEncoding) throws CompileException, java.io.IOExceptionSet 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:
CompileExceptionjava.io.IOException
-
Scanner
public Scanner(java.lang.String optionalFileName, java.io.Reader in) throws CompileException, java.io.IOExceptionSet 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:
CompileExceptionjava.io.IOException
-
Scanner
public Scanner(java.lang.String optionalFileName, java.io.Reader in, short initialLineNumber, short initialColumnNumber) throws CompileException, java.io.IOExceptionCreates aScannerthat counts lines and columns from non-default initial values.- Throws:
CompileExceptionjava.io.IOException
-
-
Method Detail
-
getFileName
public java.lang.String getFileName()
Return the file name optionally passed to the constructor.
-
close
@Deprecated public void close() throws java.io.IOExceptionDeprecated.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:
java.io.IOException
-
doc
public java.lang.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, java.io.IOException
- Throws:
CompileExceptionjava.io.IOException
-
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
-
-