org.apache.cocoon.components.language.programming.java
Class AbstractJavaCompiler

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.cocoon.components.language.programming.java.AbstractJavaCompiler
All Implemented Interfaces:
Poolable, Recyclable, Component, LogEnabled, LanguageCompiler
Direct Known Subclasses:
Javac, Jikes

public abstract class AbstractJavaCompiler
extends AbstractLogEnabled
implements LanguageCompiler, Recyclable

This class implements the functionality common to all Java compilers.

Since:
2.0
Version:
CVS $Id: AbstractJavaCompiler.html 1304258 2012-03-23 10:09:27Z ilgrosso $
Author:
Stefano Mazzocchi

Field Summary
protected  String classpath
          The classpath to be used for compilation
protected  int compilerComplianceLevel
          The version of the JVM for wich the code was written.
protected  String destDir
          The name of the directory to contain the resulting object program file
protected  String encoding
          The encoding of the source program or null to use the platform's default encoding
protected  InputStream errors
          The input stream to output compilation errors
protected  String file
          The source program filename
protected  String srcDir
          The name of the directory containing the source program file
 
Constructor Summary
AbstractJavaCompiler()
           
 
Method Summary
protected  List fillArguments(List arguments)
          Fill the arguments taken by the Java compiler
 List getErrors()
          Return the list of errors generated by this compilation
protected abstract  List parseStream(BufferedReader errors)
          Parse the compiler error stream to produce a list of CompilerErrors
 void recycle()
          Reset all internal state.
 void setClasspath(String classpath)
          Set the classpath to be used for this compilation
 void setCompilerComplianceLevel(int compilerComplianceLevel)
          Set the version of the java source code to be compiled
 void setDestination(String destDir)
          Set the name of the directory to contain the resulting object program file
 void setEncoding(String encoding)
          Set the encoding of the input source file or null to use the platform's default encoding
 void setFile(String file)
          Set the name of the file containing the source program
 void setSource(String srcDir)
          Set the name of the directory containing the source program file
protected  String[] toStringArray(List arguments)
          Copy arguments to a string array
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.cocoon.components.language.programming.LanguageCompiler
compile
 

Field Detail

file

protected String file
The source program filename


srcDir

protected String srcDir
The name of the directory containing the source program file


destDir

protected String destDir
The name of the directory to contain the resulting object program file


classpath

protected String classpath
The classpath to be used for compilation


encoding

protected String encoding
The encoding of the source program or null to use the platform's default encoding


compilerComplianceLevel

protected int compilerComplianceLevel
The version of the JVM for wich the code was written. i.e: 130 = Java 1.3, 140 = Java 1.4 and 150 = Java 1.5


errors

protected InputStream errors
The input stream to output compilation errors

Constructor Detail

AbstractJavaCompiler

public AbstractJavaCompiler()
Method Detail

setFile

public void setFile(String file)
Set the name of the file containing the source program

Specified by:
setFile in interface LanguageCompiler
Parameters:
file - The name of the file containing the source program

setSource

public void setSource(String srcDir)
Set the name of the directory containing the source program file

Specified by:
setSource in interface LanguageCompiler
Parameters:
srcDir - The name of the directory containing the source program file

setDestination

public void setDestination(String destDir)
Set the name of the directory to contain the resulting object program file

Specified by:
setDestination in interface LanguageCompiler
Parameters:
destDir - The name of the directory to contain the resulting object program file

setClasspath

public void setClasspath(String classpath)
Set the classpath to be used for this compilation

Specified by:
setClasspath in interface LanguageCompiler
Parameters:
classpath - The classpath to be used for this compilation

setEncoding

public void setEncoding(String encoding)
Set the encoding of the input source file or null to use the platform's default encoding

Specified by:
setEncoding in interface LanguageCompiler
Parameters:
encoding - The encoding of the input source file or null to use the platform's default encoding

setCompilerComplianceLevel

public void setCompilerComplianceLevel(int compilerComplianceLevel)
Set the version of the java source code to be compiled

Specified by:
setCompilerComplianceLevel in interface LanguageCompiler
Parameters:
compilerComplianceLevel - The version of the JVM for wich the code was written. i.e: 130 = Java 1.3, 140 = Java 1.4 and 150 = Java 1.5
Since:
2.1.7

getErrors

public List getErrors()
               throws IOException
Return the list of errors generated by this compilation

Specified by:
getErrors in interface LanguageCompiler
Returns:
The list of errors generated by this compilation
Throws:
IOException - If an error occurs during message collection

parseStream

protected abstract List parseStream(BufferedReader errors)
                             throws IOException
Parse the compiler error stream to produce a list of CompilerErrors

Parameters:
errors - The error stream
Returns:
The list of compiler error messages
Throws:
IOException - If an error occurs during message collection

fillArguments

protected List fillArguments(List arguments)
Fill the arguments taken by the Java compiler

Parameters:
arguments - The list of compilation arguments
Returns:
The prepared list of compilation arguments

toStringArray

protected String[] toStringArray(List arguments)
Copy arguments to a string array

Parameters:
arguments - The compiler arguments
Returns:
A string array containing compilation arguments

recycle

public void recycle()
Reset all internal state. This method is called by the component manager before this component is return to its pool.

Specified by:
recycle in interface Recyclable


Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.