|
Web Site | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.codehaus.janino.Scanner
Splits up a character stream into tokens and returns them as
String
objects.
The optionalFileName
parameter passed to many
constructors should point
Nested Class Summary | |
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
String STRING literal
Character CHAR literal
Integer INT literal
Long LONG literal
Float FLOAT literal
Double DOUBLE literal
Boolean BOOLEAN literal
null NULL literal
|
static class |
Scanner.LocatedException
|
class |
Scanner.OperatorToken
|
class |
Scanner.ScanException
An exception that reflects an error during parsing. |
class |
Scanner.Token
|
Field Summary | |
static Integer |
MAGIC_INTEGER
This value represents the "magic" literal "2147483648" which is only allowed in a negated context. |
static Long |
MAGIC_LONG
This value represents the "magic" literal "9223372036854775808L" which is only allowed in a negated context. |
Constructor Summary | |
Scanner(File file)
Set up a scanner that reads tokens from the given file in the platform default encoding. |
|
Scanner(File file,
String encoding)
Set up a scanner that reads tokens from the given file in the given encoding. |
|
Scanner(String fileName)
Set up a scanner that reads tokens from the given file in the platform default encoding. |
|
Scanner(String fileName,
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. |
Method Summary | |
void |
close()
Closes the character source (file, InputStream , Reader ) associated
with this object. |
String |
doc()
Get the text of the doc comment (a.k.a. |
static String |
literalValueToString(Object v)
|
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. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final Integer MAGIC_INTEGER
public static final Long MAGIC_LONG
Constructor Detail |
public Scanner(String fileName) throws Scanner.ScanException, IOException
Don't forget to close()
when you're done, so the input file is closed.
fileName
-
Scanner.ScanException
IOException
public Scanner(File file) throws Scanner.ScanException, IOException
Don't forget to close()
when you're done, so the input file is closed.
file
-
Scanner.ScanException
IOException
public Scanner(File file, String encoding) throws Scanner.ScanException, IOException
Don't forget to close()
when you're done, so the input file is closed.
file
- encoding
-
Scanner.ScanException
IOException
public Scanner(String fileName, InputStream is) throws Scanner.ScanException, IOException
InputStream
in the platform default encoding.
The fileName
is solely used for reporting in thrown
exceptions.
fileName
- is
-
Scanner.ScanException
IOException
public Scanner(String optionalFileName, InputStream is, String optionalEncoding) throws Scanner.ScanException, 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.
public Scanner(String optionalFileName, Reader in) throws Scanner.ScanException, 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.
public Scanner(String optionalFileName, Reader in, short initialLineNumber, short initialColumnNumber) throws Scanner.ScanException, IOException
Scanner
that counts lines and columns from non-default initial
values.
Method Detail |
public void close() throws IOException
InputStream
, Reader
) associated
with this object. The results of future calls to peek()
and
read()
are undefined.
IOException
public Scanner.Token read() throws Scanner.ScanException, IOException
Scanner.ScanException
IOException
public Scanner.Token peek()
public Scanner.Token peekNextButOne() throws Scanner.ScanException, IOException
Scanner.ScanException
IOException
public String doc()
null
if the next token is not preceeded by a doc commentpublic static String literalValueToString(Object v)
|
Web Site | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |