| Modifier and Type | Class and Description |
|---|---|
class |
Scanner.EOFToken |
class |
Scanner.IdentifierToken |
class |
Scanner.KeywordToken |
class |
Scanner.LiteralToken
The type of the
value parameter determines the type of the literal
token:
Type/value returned by Scanner.LiteralToken.getLiteralValue()Literal
StringSTRING literal
CharacterCHAR literal
IntegerINT literal
LongLONG literal
FloatFLOAT literal
DoubleDOUBLE literal
BooleanBOOLEAN literal
nullNULL literal
|
class |
Scanner.Token |
| Modifier and Type | Field and Description |
|---|---|
static Integer |
MAGIC_INTEGER
This reference represents the "magic" literal "2147483648" which is only
allowed in a negated context.
|
static Long |
MAGIC_LONG
This reference represents the "magic" literal "9223372036854775808L" which is only
allowed in a negated context.
|
| Constructor and Description |
|---|
Scanner(File file)
Deprecated.
|
Scanner(File file,
String optionalEncoding)
Deprecated.
|
Scanner(String fileName)
Deprecated.
|
Scanner(String optionalFileName,
InputStream is)
Set up a scanner that reads tokens from the given
InputStream in the platform default encoding. |
Scanner(String optionalFileName,
InputStream is,
String optionalEncoding)
Set up a scanner that reads tokens from the given
InputStream with the given optionalEncoding
(null means platform default encoding). |
Scanner(String optionalFileName,
Reader in)
Set up a scanner that reads tokens from the given
Reader. |
Scanner(String optionalFileName,
Reader in,
short initialLineNumber,
short initialColumnNumber)
Creates a
Scanner that counts lines and columns from non-default initial
values. |
Scanner(String fileName,
String encoding)
Deprecated.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Deprecated.
|
String |
doc()
Get the text of the doc comment (a.k.a.
|
String |
getFileName()
Return the file name optionally passed to the constructor.
|
static String |
literalValueToString(Object v) |
Location |
location()
Returns the
Location of the next token. |
Scanner.Token |
peek()
Peek the next token, but don't remove it from the input.
|
Scanner.Token |
peekNextButOne()
Peek the next but one token, neither remove the next nor the next but one token from the
input.
|
Scanner.Token |
read()
Read the next token from the input.
|
void |
setWarningHandler(WarningHandler optionalWarningHandler)
By default, warnings are discarded, but an application my install a
WarningHandler. |
public static final Integer MAGIC_INTEGER
public static final Long MAGIC_LONG
public Scanner(String fileName) throws CompileException, IOException
This method is deprecated because it leaves the input file open.
CompileExceptionIOExceptionpublic Scanner(String fileName, String encoding) throws CompileException, IOException
This method is deprecated because it leaves the input file open.
CompileExceptionIOExceptionpublic Scanner(File file) throws CompileException, IOException
This method is deprecated because it leaves the input file open.
CompileExceptionIOExceptionpublic Scanner(File file, String optionalEncoding) throws CompileException, IOException
This method is deprecated because it leaves the input file open.
CompileExceptionIOExceptionpublic Scanner(String optionalFileName, InputStream is) throws CompileException, IOException
InputStream in the platform default encoding.
The fileName is solely used for reporting in thrown
exceptions.
CompileExceptionIOExceptionpublic Scanner(String optionalFileName, InputStream is, String optionalEncoding) throws CompileException, 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.
CompileExceptionIOExceptionpublic Scanner(String optionalFileName, Reader in) throws CompileException, 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.
CompileExceptionIOExceptionpublic Scanner(String optionalFileName, Reader in, short initialLineNumber, short initialColumnNumber) throws CompileException, IOException
Scanner that counts lines and columns from non-default initial
values.CompileExceptionIOExceptionpublic String getFileName()
public void close()
throws IOException
InputStream, Reader) associated
with this object. The results of future calls to peek() and
read() are undefined.
This method is deprecated, because the concept described above is confusing. An
application should close the underlying InputStream or Reader itself.
IOExceptionpublic Scanner.Token read() throws CompileException, IOException
CompileExceptionIOExceptionpublic Scanner.Token peek()
public Scanner.Token peekNextButOne() throws CompileException, IOException
This makes parsing so much easier, e.g. for class literals like
Map.class.
CompileExceptionIOExceptionpublic String doc()
null if the next token is not preceeded by a doc commentpublic 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 issuedCopyright © 2001-2012. All Rights Reserved.