|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.codehaus.janino.Scanner
public class 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
StringSTRING literal
CharacterCHAR literal
IntegerINT literal
LongLONG literal
FloatFLOAT literal
DoubleDOUBLE literal
BooleanBOOLEAN literal
nullNULL literal
|
class |
Scanner.Token
|
| Field Summary | |
|---|---|
static java.lang.Integer |
MAGIC_INTEGER
This reference represents the "magic" literal "2147483648" which is only allowed in a negated context. |
static java.lang.Long |
MAGIC_LONG
This reference represents the "magic" literal "9223372036854775808L" which is only allowed in a negated context. |
| Constructor Summary | |
|---|---|
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. |
|
| Method Summary | |
|---|---|
void |
close()
Deprecated. |
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. |
static java.lang.String |
literalValueToString(java.lang.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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.Integer MAGIC_INTEGER
public static final java.lang.Long MAGIC_LONG
| Constructor Detail |
|---|
public Scanner(java.lang.String fileName)
throws CompileException,
java.io.IOException
This method is deprecated because it leaves the input file open.
CompileException
java.io.IOException
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.
CompileException
java.io.IOException
public Scanner(java.io.File file)
throws CompileException,
java.io.IOException
This method is deprecated because it leaves the input file open.
CompileException
java.io.IOException
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.
CompileException
java.io.IOException
public 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.
CompileException
java.io.IOException
public 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.
CompileException
java.io.IOException
public 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.
CompileException
java.io.IOException
public 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.
CompileException
java.io.IOException| Method Detail |
|---|
public java.lang.String getFileName()
public void close()
throws java.io.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.
java.io.IOException
public Scanner.Token read()
throws CompileException,
java.io.IOException
CompileException
java.io.IOExceptionpublic Scanner.Token peek()
public Scanner.Token peekNextButOne()
throws CompileException,
java.io.IOException
This makes parsing so much easier, e.g. for class literals like
Map.class.
CompileException
java.io.IOExceptionpublic java.lang.String doc()
null if the next token is not preceeded by a doc commentpublic Location location()
Location of the next token.
public static java.lang.String literalValueToString(java.lang.Object v)
public 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
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||