Top Description Methods
org.codehaus.commons.compiler

public Interface ICookable

Known Direct Subinterfaces
org.codehaus.commons.compiler.IExpressionEvaluator, org.codehaus.commons.compiler.IScriptEvaluator, org.codehaus.commons.compiler.ISimpleCompiler, org.codehaus.commons.compiler.IClassBodyEvaluator
Known Direct Implementers
org.codehaus.commons.compiler.Cookable
Imports
java.io.File, .IOException, .InputStream, .Reader, java.util.Map, org.codehaus.commons.nullanalysis.Nullable

An entity that processes a sequence of characters (a "document"). For example, if you cook an IClassBodyEvaluator, then the tokens are interpreted as a Java class body and compiled into a Class which is accessible through IClassBodyEvaluator#getClazz().

Method Summary

Modifier and TypeMethod and Description
public void
cook(String
Used when reporting errors and warnings
fileName
,
Reader r)

Reads, scans, parses and compiles Java tokens from the given Reader.

public void
cook(Reader r)

Reads, scans, parses and compiles Java tokens from the given Reader.

public void
cook(InputStream is)

Reads, scans, parses and compiles Java tokens from the given InputStream, encoded in the "platform default encoding".

public void
cook(String
Used when reporting errors and warnings
fileName
,
InputStream is)

Reads, scans, parses and compiles Java tokens from the given InputStream, encoded in the "platform default encoding".

public void
cook(InputStream is, String encoding)

Reads, scans, parses and compiles Java tokens from the given InputStream with the given encoding.

public void
cook(String
Used when reporting errors and warnings
fileName
,
InputStream is, String encoding)

Reads, scans, parses and compiles Java tokens from the given InputStream with the given encoding.

public void
cook(String s)

Reads, scans, parses and compiles Java tokens from the given String.

public void
cook(String
Used when reporting errors and warnings
fileName
,
String s)

Reads, scans, parses and compiles Java tokens from the given String.

public void
cookFile(File file)

Reads, scans, parses and compiles Java tokens from the given File, encoded in the "platform default encoding".

public void
cookFile(File file, String encoding)

Reads, scans, parses and compiles Java tokens from the given File with the given encoding.

public void
cookFile(String fileName)

Reads, scans, parses and compiles Java tokens from the named file, encoded in the "platform default encoding".

public void
cookFile(String fileName, String encoding)

Reads, scans, parses and compiles Java tokens from the named file with the given encoding.

public Map<String, byte[]>

Returns:

The generated Java bytecode; maps class name to bytes
getBytecodes
()

public void
setSourceVersion(int version)

Specifies the version of source code accepted, in analogy with JAVAC's -source command line option.

public 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

cookback to summary
public void cook(String fileName, Reader r) throws CompileException, IOException

Reads, scans, parses and compiles Java tokens from the given Reader.

Parameters
fileName:String

Used when reporting errors and warnings

cookback to summary
public void cook(Reader r) throws CompileException, IOException

Reads, scans, parses and compiles Java tokens from the given Reader.

cookback to summary
public void cook(InputStream is) throws CompileException, IOException

Reads, scans, parses and compiles Java tokens from the given InputStream, encoded in the "platform default encoding".

cookback to summary
public void cook(String fileName, InputStream is) throws CompileException, IOException

Reads, scans, parses and compiles Java tokens from the given InputStream, encoded in the "platform default encoding".

Parameters
fileName:String

Used when reporting errors and warnings

cookback to summary
public void cook(InputStream is, String encoding) throws CompileException, IOException

Reads, scans, parses and compiles Java tokens from the given InputStream with the given encoding.

cookback to summary
public void cook(String fileName, InputStream is, String encoding) throws CompileException, IOException

Reads, scans, parses and compiles Java tokens from the given InputStream with the given encoding.

Parameters
fileName:String

Used when reporting errors and warnings

cookback to summary
public void cook(String s) throws CompileException

Reads, scans, parses and compiles Java tokens from the given String.

cookback to summary
public void cook(String fileName, String s) throws CompileException

Reads, scans, parses and compiles Java tokens from the given String.

Parameters
fileName:String

Used when reporting errors and warnings

cookFileback to summary
public void cookFile(File file) throws CompileException, IOException

Reads, scans, parses and compiles Java tokens from the given File, encoded in the "platform default encoding".

cookFileback to summary
public void cookFile(File file, String encoding) throws CompileException, IOException

Reads, scans, parses and compiles Java tokens from the given File with the given encoding.

cookFileback to summary
public void cookFile(String fileName) throws CompileException, IOException

Reads, scans, parses and compiles Java tokens from the named file, encoded in the "platform default encoding".

cookFileback to summary
public void cookFile(String fileName, String encoding) throws CompileException, IOException

Reads, scans, parses and compiles Java tokens from the named file with the given encoding.

getBytecodesback to summary
public Map<String, byte[]> getBytecodes()
Returns:Map<String, byte[]>

The generated Java bytecode; maps class name to bytes

Exceptions
IllegalStateException:
This IClassBodyEvaluator is not yet cooked
setSourceVersionback to summary
public 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. the janino 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.

setTargetVersionback to summary
public 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.