Package org.codehaus.commons.compiler
Interface ICookable
-
- All Known Subinterfaces:
IClassBodyEvaluator
,IExpressionEvaluator
,IScriptEvaluator
,ISimpleCompiler
- All Known Implementing Classes:
ClassBodyEvaluator
,ClassBodyEvaluator
,Cookable
,ExpressionEvaluator
,ExpressionEvaluator
,MultiCookable
,ScriptEvaluator
,ScriptEvaluator
,SimpleCompiler
,SimpleCompiler
public interface ICookable
An entity that processes a sequence of characters (a "document"). For example, if you cook anIClassBodyEvaluator
, then the tokens are interpreted as a Java class body and compiled into aClass
which is accessible throughIClassBodyEvaluator.getClazz()
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
cook(java.io.InputStream is)
Reads, scans, parses and compiles Java tokens from the givenInputStream
, encoded in the "platform default encoding".void
cook(java.io.InputStream is, java.lang.String encoding)
Reads, scans, parses and compiles Java tokens from the givenInputStream
with the givenencoding
.void
cook(java.io.Reader r)
Reads, scans, parses and compiles Java tokens from the givenReader
.void
cook(java.lang.String s)
Reads, scans, parses and compiles Java tokens from the givenString
.void
cook(java.lang.String fileName, java.io.InputStream is)
Reads, scans, parses and compiles Java tokens from the givenInputStream
, encoded in the "platform default encoding".void
cook(java.lang.String fileName, java.io.InputStream is, java.lang.String encoding)
Reads, scans, parses and compiles Java tokens from the givenInputStream
with the givenencoding
.void
cook(java.lang.String fileName, java.io.Reader r)
Reads, scans, parses and compiles Java tokens from the givenReader
.void
cook(java.lang.String fileName, java.lang.String s)
Reads, scans, parses and compiles Java tokens from the givenString
.void
cookFile(java.io.File file)
Reads, scans, parses and compiles Java tokens from the givenFile
, encoded in the "platform default encoding".void
cookFile(java.io.File file, java.lang.String encoding)
Reads, scans, parses and compiles Java tokens from the givenFile
with the givenencoding
.void
cookFile(java.lang.String fileName)
Reads, scans, parses and compiles Java tokens from the named file, encoded in the "platform default encoding".void
cookFile(java.lang.String fileName, java.lang.String encoding)
Reads, scans, parses and compiles Java tokens from the named file with the given encoding.java.util.Map<java.lang.String,byte[]>
getBytecodes()
void
setSourceVersion(int version)
Specifies the version of source code accepted, in analogy with JAVAC's-source
command line option.void
setTargetVersion(int version)
Generates class files that target a specified release of the virtual machine, in analogy with JAVAC's-target
command line option.
-
-
-
Method Detail
-
cook
void cook(@Nullable java.lang.String fileName, java.io.Reader r) throws CompileException, java.io.IOException
Reads, scans, parses and compiles Java tokens from the givenReader
.- Parameters:
fileName
- Used when reporting errors and warnings- Throws:
CompileException
java.io.IOException
-
cook
void cook(java.io.Reader r) throws CompileException, java.io.IOException
Reads, scans, parses and compiles Java tokens from the givenReader
.- Throws:
CompileException
java.io.IOException
-
cook
void cook(java.io.InputStream is) throws CompileException, java.io.IOException
Reads, scans, parses and compiles Java tokens from the givenInputStream
, encoded in the "platform default encoding".- Throws:
CompileException
java.io.IOException
-
cook
void cook(@Nullable java.lang.String fileName, java.io.InputStream is) throws CompileException, java.io.IOException
Reads, scans, parses and compiles Java tokens from the givenInputStream
, encoded in the "platform default encoding".- Parameters:
fileName
- Used when reporting errors and warnings- Throws:
CompileException
java.io.IOException
-
cook
void cook(java.io.InputStream is, @Nullable java.lang.String encoding) throws CompileException, java.io.IOException
Reads, scans, parses and compiles Java tokens from the givenInputStream
with the givenencoding
.- Throws:
CompileException
java.io.IOException
-
cook
void cook(@Nullable java.lang.String fileName, java.io.InputStream is, @Nullable java.lang.String encoding) throws CompileException, java.io.IOException
Reads, scans, parses and compiles Java tokens from the givenInputStream
with the givenencoding
.- Parameters:
fileName
- Used when reporting errors and warnings- Throws:
CompileException
java.io.IOException
-
cook
void cook(java.lang.String s) throws CompileException
Reads, scans, parses and compiles Java tokens from the givenString
.- Throws:
CompileException
-
cook
void cook(@Nullable java.lang.String fileName, java.lang.String s) throws CompileException
Reads, scans, parses and compiles Java tokens from the givenString
.- Parameters:
fileName
- Used when reporting errors and warnings- Throws:
CompileException
-
cookFile
void cookFile(java.io.File file) throws CompileException, java.io.IOException
Reads, scans, parses and compiles Java tokens from the givenFile
, encoded in the "platform default encoding".- Throws:
CompileException
java.io.IOException
-
cookFile
void cookFile(java.io.File file, @Nullable java.lang.String encoding) throws CompileException, java.io.IOException
Reads, scans, parses and compiles Java tokens from the givenFile
with the givenencoding
.- Throws:
CompileException
java.io.IOException
-
cookFile
void cookFile(java.lang.String fileName) throws CompileException, java.io.IOException
Reads, scans, parses and compiles Java tokens from the named file, encoded in the "platform default encoding".- Throws:
CompileException
java.io.IOException
-
cookFile
void cookFile(java.lang.String fileName, @Nullable java.lang.String encoding) throws CompileException, java.io.IOException
Reads, scans, parses and compiles Java tokens from the named file with the given encoding.- Throws:
CompileException
java.io.IOException
-
setSourceVersion
void setSourceVersion(int version)
Specifies the version of source code accepted, in analogy with JAVAC's-source
command line option. May be ignored by an implementation (e.g. thejanino
implementation always accepts the language features as described on the home page). Allowed values, and the default value, depend on the implementation.-1
means to use a default version.
-
setTargetVersion
void setTargetVersion(int version)
Generates class files that target a specified release of the virtual machine, in analogy with JAVAC's-target
command line option. Allowed values depend on the implementation. The default value also depends on the implementation. The only invariant is that the generated class files are suitable for the currently executing JVM.-1
means to use a default version.
-
getBytecodes
java.util.Map<java.lang.String,byte[]> getBytecodes()
- Returns:
- The generated Java bytecode; maps class name to bytes
- Throws:
java.lang.IllegalStateException
- This IClassBodyEvaluator is not yet cooked
-
-