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 ICookableAn 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 aClasswhich is accessible throughIClassBodyEvaluator.getClazz().
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidcook(java.io.InputStream is)Reads, scans, parses and compiles Java tokens from the givenInputStream, encoded in the "platform default encoding".voidcook(java.io.InputStream is, java.lang.String encoding)Reads, scans, parses and compiles Java tokens from the givenInputStreamwith the givenencoding.voidcook(java.io.Reader r)Reads, scans, parses and compiles Java tokens from the givenReader.voidcook(java.lang.String s)Reads, scans, parses and compiles Java tokens from the givenString.voidcook(java.lang.String fileName, java.io.InputStream is)Reads, scans, parses and compiles Java tokens from the givenInputStream, encoded in the "platform default encoding".voidcook(java.lang.String fileName, java.io.InputStream is, java.lang.String encoding)Reads, scans, parses and compiles Java tokens from the givenInputStreamwith the givenencoding.voidcook(java.lang.String fileName, java.io.Reader r)Reads, scans, parses and compiles Java tokens from the givenReader.voidcook(java.lang.String fileName, java.lang.String s)Reads, scans, parses and compiles Java tokens from the givenString.voidcookFile(java.io.File file)Reads, scans, parses and compiles Java tokens from the givenFile, encoded in the "platform default encoding".voidcookFile(java.io.File file, java.lang.String encoding)Reads, scans, parses and compiles Java tokens from the givenFilewith the givenencoding.voidcookFile(java.lang.String fileName)Reads, scans, parses and compiles Java tokens from the named file, encoded in the "platform default encoding".voidcookFile(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()voidsetSourceVersion(int version)Specifies the version of source code accepted, in analogy with JAVAC's-sourcecommand line option.voidsetTargetVersion(int version)Generates class files that target a specified release of the virtual machine, in analogy with JAVAC's-targetcommand 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:
CompileExceptionjava.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:
CompileExceptionjava.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:
CompileExceptionjava.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:
CompileExceptionjava.io.IOException
-
cook
void cook(java.io.InputStream is, @Nullable java.lang.String encoding) throws CompileException, java.io.IOExceptionReads, scans, parses and compiles Java tokens from the givenInputStreamwith the givenencoding.- Throws:
CompileExceptionjava.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 givenInputStreamwith the givenencoding.- Parameters:
fileName- Used when reporting errors and warnings- Throws:
CompileExceptionjava.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.IOExceptionReads, scans, parses and compiles Java tokens from the givenFile, encoded in the "platform default encoding".- Throws:
CompileExceptionjava.io.IOException
-
cookFile
void cookFile(java.io.File file, @Nullable java.lang.String encoding) throws CompileException, java.io.IOExceptionReads, scans, parses and compiles Java tokens from the givenFilewith the givenencoding.- Throws:
CompileExceptionjava.io.IOException
-
cookFile
void cookFile(java.lang.String fileName) throws CompileException, java.io.IOExceptionReads, scans, parses and compiles Java tokens from the named file, encoded in the "platform default encoding".- Throws:
CompileExceptionjava.io.IOException
-
cookFile
void cookFile(java.lang.String fileName, @Nullable java.lang.String encoding) throws CompileException, java.io.IOExceptionReads, scans, parses and compiles Java tokens from the named file with the given encoding.- Throws:
CompileExceptionjava.io.IOException
-
setSourceVersion
void setSourceVersion(int version)
Specifies the version of source code accepted, in analogy with JAVAC's-sourcecommand line option. May be ignored by an implementation (e.g. thejaninoimplementation always accepts the language features as described on the home page). Allowed values, and the default value, depend on the implementation.-1means 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-targetcommand 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.-1means 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
-
-