Class Scanner
- java.lang.Object
-
- org.codehaus.janino.Scanner
-
-
Field Summary
Fields Modifier and Type Field Description static StringSYSTEM_PROPERTY_SOURCE_DEBUGGING_DIRIf the source code is not read from a file, debuggers have a hard time locating the source file for source-level debugging.static StringSYSTEM_PROPERTY_SOURCE_DEBUGGING_ENABLESetting this system property to 'true' enables source-level debugging.static StringSYSTEM_PROPERTY_SOURCE_DEBUGGING_KEEPIf set to "true", then the temporary source code files are not deleted on exit.
-
Constructor Summary
Constructors Constructor Description Scanner(File file)Deprecated.This method is deprecated because it leaves the input file openScanner(File file, String encoding)Deprecated.This method is deprecated because it leaves the input file openScanner(String fileName)Deprecated.This method is deprecated because it leaves the input file openScanner(String fileName, InputStream is)Sets up a scanner that reads tokens from the givenInputStreamin the platform default encoding.Scanner(String fileName, InputStream is, String encoding)Sets up a scanner that reads tokens from the givenInputStreamwith the given encoding (nullmeans platform default encoding).Scanner(String fileName, Reader in)Sets up a scanner that reads tokens from the givenReader.Scanner(String fileName, Reader in, int initialLineNumber, int initialColumnNumber)Creates aScannerthat counts lines and columns from non-default initial values.Scanner(String fileName, String encoding)Deprecated.This method is deprecated because it leaves the input file open
-
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.StringgetFileName()Locationlocation()Tokenproduce()Produces and returns the next token.voidsetIgnoreWhiteSpace(boolean value)If value istrue, then white space in the input stream is ignored, rather than scanned as aTokenType.WHITE_SPACEtoken.
-
-
-
Field Detail
-
SYSTEM_PROPERTY_SOURCE_DEBUGGING_ENABLE
public static final String SYSTEM_PROPERTY_SOURCE_DEBUGGING_ENABLE
Setting this system property to 'true' enables source-level debugging. Typically, this means that compilation is executed with "-g:all" instead of "-g:none".- See Also:
- Constant Field Values
-
SYSTEM_PROPERTY_SOURCE_DEBUGGING_DIR
public static final String SYSTEM_PROPERTY_SOURCE_DEBUGGING_DIR
If the source code is not read from a file, debuggers have a hard time locating the source file for source-level debugging. As a workaround, a copy of the source code is written to a temporary file, which must be included in the debugger's source path. If this system property is set, the temporary source file is created in that directory, otherwise in the default temporary-file directory.
-
SYSTEM_PROPERTY_SOURCE_DEBUGGING_KEEP
public static final String SYSTEM_PROPERTY_SOURCE_DEBUGGING_KEEP
If set to "true", then the temporary source code files are not deleted on exit. That may be useful to interpret stack traces offline.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Scanner
@Deprecated public Scanner(String fileName) throws IOException
Deprecated.This method is deprecated because it leaves the input file open- Throws:
IOException
-
Scanner
@Deprecated public Scanner(String fileName, String encoding) throws IOException
Deprecated.This method is deprecated because it leaves the input file open- Throws:
IOException
-
Scanner
@Deprecated public Scanner(File file) throws IOException
Deprecated.This method is deprecated because it leaves the input file open- Throws:
IOException
-
Scanner
@Deprecated public Scanner(File file, @Nullable String encoding) throws IOException
Deprecated.This method is deprecated because it leaves the input file open- Throws:
IOException
-
Scanner
public Scanner(@Nullable String fileName, InputStream is) throws IOException
Sets up a scanner that reads tokens from the givenInputStreamin the platform default encoding.The fileName is solely used for reporting in thrown exceptions.
- Throws:
IOException
-
Scanner
public Scanner(@Nullable String fileName, InputStream is, @Nullable String encoding) throws IOException
Sets up a scanner that reads tokens from the givenInputStreamwith the given encoding (nullmeans platform default encoding).The fileName is used for reporting errors during compilation and for source level debugging, and should name an existing file. If
nullis 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:
IOException
-
Scanner
public Scanner(@Nullable String fileName, Reader in) throws IOException
Sets up a scanner that reads tokens from the givenReader.The fileName is used for reporting errors during compilation and for source level debugging, and should name an existing file. If
nullis 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:
IOException
-
Scanner
public Scanner(@Nullable String fileName, Reader in, int initialLineNumber, int initialColumnNumber) throws IOException
Creates aScannerthat counts lines and columns from non-default initial values.- Throws:
IOException
-
-
Method Detail
-
setIgnoreWhiteSpace
public void setIgnoreWhiteSpace(boolean value)
If value istrue, then white space in the input stream is ignored, rather than scanned as aTokenType.WHITE_SPACEtoken. Since white space is typically quite numerous, this optimization may save considerable overhead.
-
getFileName
@Nullable 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 underlyingInputStreamorReaderitselfCloses the character source (file,InputStream,Reader) associated with this object. The results of future calls toproduce()are undefined.- Throws:
IOException
-
produce
public Token produce() throws CompileException, IOException
Produces and returns the next token. Notice that end-of-input is not signalized with anullproduct, but by anTokenType.END_OF_INPUT-type token.- Throws:
CompileExceptionIOException
-
-