public class Scanner
extends java.lang.Object
String objects.
The optionalFileName parameter passed to many
constructors should point
| Modifier and Type | Class and Description |
|---|---|
class |
Scanner.Token |
| Constructor and 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 given
InputStream in 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 given
InputStream with the given optionalEncoding
(null means platform default encoding). |
Scanner(java.lang.String optionalFileName,
java.io.Reader in)
Set up a scanner that reads tokens from the given
Reader. |
Scanner(java.lang.String optionalFileName,
java.io.Reader in,
short initialLineNumber,
short initialColumnNumber)
Creates a
Scanner that counts lines and columns from non-default initial
values. |
Scanner(java.lang.String fileName,
java.lang.String encoding)
Deprecated.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Deprecated.
This method is deprecated, because the concept described above is confusing. An application should
close the underlying
InputStream or Reader itself. |
java.lang.String |
doc()
Get the text of the doc comment (a.k.a.
|
java.lang.String |
getFileName()
Return the file name optionally passed to the constructor.
|
Location |
location()
Returns the
Location of the next character. |
Scanner.Token |
produce() |
void |
setWarningHandler(WarningHandler optionalWarningHandler)
By default, warnings are discarded, but an application my install a
WarningHandler. |
@Deprecated
public Scanner(java.lang.String fileName)
throws CompileException,
java.io.IOException
This method is deprecated because it leaves the input file open.
CompileExceptionjava.io.IOException@Deprecated
public Scanner(java.lang.String fileName,
java.lang.String encoding)
throws CompileException,
java.io.IOException
This method is deprecated because it leaves the input file open.
CompileExceptionjava.io.IOException@Deprecated
public Scanner(java.io.File file)
throws CompileException,
java.io.IOException
This method is deprecated because it leaves the input file open.
CompileExceptionjava.io.IOException@Deprecated
public Scanner(java.io.File file,
java.lang.String optionalEncoding)
throws CompileException,
java.io.IOException
This method is deprecated because it leaves the input file open.
CompileExceptionjava.io.IOExceptionpublic Scanner(java.lang.String optionalFileName,
java.io.InputStream is)
throws CompileException,
java.io.IOException
InputStream in the platform default encoding.
The fileName is solely used for reporting in thrown
exceptions.
CompileExceptionjava.io.IOExceptionpublic Scanner(java.lang.String optionalFileName,
java.io.InputStream is,
java.lang.String optionalEncoding)
throws CompileException,
java.io.IOException
InputStream 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.
CompileExceptionjava.io.IOExceptionpublic Scanner(java.lang.String optionalFileName,
java.io.Reader in)
throws CompileException,
java.io.IOException
Reader.
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.
CompileExceptionjava.io.IOExceptionpublic Scanner(java.lang.String optionalFileName,
java.io.Reader in,
short initialLineNumber,
short initialColumnNumber)
throws CompileException,
java.io.IOException
Scanner that counts lines and columns from non-default initial
values.CompileExceptionjava.io.IOExceptionpublic java.lang.String getFileName()
@Deprecated
public void close()
throws java.io.IOException
InputStream or Reader itself.InputStream, Reader) associated with this object. The results
of future calls to produce() are undefined.java.io.IOExceptionpublic java.lang.String doc()
null if the next token is not preceeded by a doc commentpublic Scanner.Token produce() throws CompileException, java.io.IOException
CompileExceptionjava.io.IOExceptionpublic void setWarningHandler(WarningHandler optionalWarningHandler)
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.
optionalWarningHandler - null to indicate that no warnings be issued