Class Scanner
String
objects.
The optionalFileName
parameter passed to many
constructors should point
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionDeprecated.Deprecated.Deprecated.Scanner
(String optionalFileName, InputStream is) Set up a scanner that reads tokens from the givenInputStream
in the platform default encoding.Scanner
(String optionalFileName, InputStream is, String optionalEncoding) Set up a scanner that reads tokens from the givenInputStream
with the givenoptionalEncoding
(null
means platform default encoding).Set up a scanner that reads tokens from the givenReader
.Creates aScanner
that counts lines and columns from non-default initial values.Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Deprecated.This method is deprecated, because the concept described above is confusing.doc()
Get the text of the doc comment (a.k.a.Return the file name optionally passed to the constructor.location()
Returns theLocation
of the next character.produce()
void
setWarningHandler
(WarningHandler optionalWarningHandler) By default, warnings are discarded, but an application my install aWarningHandler
.
-
Constructor Details
-
Scanner
Deprecated.Set up a scanner that reads tokens from the given file in the default charset.This method is deprecated because it leaves the input file open.
- Throws:
CompileException
IOException
-
Scanner
Deprecated.Set up a scanner that reads tokens from the given file in the given encoding.This method is deprecated because it leaves the input file open.
- Throws:
CompileException
IOException
-
Scanner
Deprecated.Set up a scanner that reads tokens from the given file in the platform default encoding.This method is deprecated because it leaves the input file open.
- Throws:
CompileException
IOException
-
Scanner
Deprecated.Set up a scanner that reads tokens from the given file in the given encoding.This method is deprecated because it leaves the input file open.
- Throws:
CompileException
IOException
-
Scanner
Set up a scanner that reads tokens from the givenInputStream
in the platform default encoding.The
fileName
is solely used for reporting in thrown exceptions.- Throws:
CompileException
IOException
-
Scanner
public Scanner(String optionalFileName, InputStream is, String optionalEncoding) throws CompileException, IOException Set up a scanner that reads tokens from the givenInputStream
with the givenoptionalEncoding
(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. Ifnull
is passed, and the system propertyorg.codehaus.janino.source_debugging.enable
is set to "true", then a temporary file inorg.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.- Throws:
CompileException
IOException
-
Scanner
Set up a scanner that reads tokens from the givenReader
.The
optionalFileName
is used for reporting errors during compilation and for source level debugging, and should name an existing file. Ifnull
is passed, and the system propertyorg.codehaus.janino.source_debugging.enable
is set to "true", then a temporary file inorg.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.- Throws:
CompileException
IOException
-
Scanner
public Scanner(String optionalFileName, Reader in, short initialLineNumber, short initialColumnNumber) throws CompileException, IOException Creates aScanner
that counts lines and columns from non-default initial values.- Throws:
CompileException
IOException
-
-
Method Details
-
getFileName
Return the file name optionally passed to the constructor. -
close
Deprecated.This method is deprecated, because the concept described above is confusing. An application should close the underlyingInputStream
orReader
itself.Closes the character source (file,InputStream
,Reader
) associated with this object. The results of future calls toproduce()
are undefined.- Throws:
IOException
-
doc
Get the text of the doc comment (a.k.a. "JAVADOC comment") preceeding the next token.- Returns:
null
if the next token is not preceeded by a doc comment
-
location
Returns theLocation
of the next character. -
produce
- Throws:
CompileException
IOException
-
setWarningHandler
By default, warnings are discarded, but an application my install aWarningHandler
.Notice that there is no
Scanner.setErrorHandler()
method, but scan errors always throw aCompileException
. 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.- Parameters:
optionalWarningHandler
-null
to indicate that no warnings be issued
-