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

java.lang.Object
  |
  +--org.apache.avalon.framework.logger.AbstractLoggable
        |
        +--org.apache.cocoon.components.language.programming.java.AbstractJavaCompiler
All Implemented Interfaces:
org.apache.avalon.framework.component.Component, LanguageCompiler, org.apache.avalon.framework.logger.Loggable, org.apache.avalon.excalibur.pool.Poolable, org.apache.avalon.excalibur.pool.Recyclable
Direct Known Subclasses:
Javac, Jikes

public abstract class AbstractJavaCompiler
extends org.apache.avalon.framework.logger.AbstractLoggable
implements LanguageCompiler, org.apache.avalon.excalibur.pool.Recyclable

This class implements the functionality common to all Java compilers.

Since:
2.0
Version:
CVS $Id: AbstractJavaCompiler.java,v 1.7 2002/03/29 20:32:01 vgritsenko Exp $
Author:
Stefano Mazzocchi

Field Summary
protected  java.lang.String classpath
          The classpath to be used for compilation
protected  java.lang.String destDir
          The name of the directory to contain the resulting object program file
protected  java.lang.String encoding
          The encoding of the source program or null to use the platform's default encoding
protected  java.io.InputStream errors
          The input stream to output compilation errors
protected  java.lang.String file
          The source program filename
protected  java.lang.String srcDir
          The name of the directory containing the source program file
 
Constructor Summary
AbstractJavaCompiler()
           
 
Method Summary
protected  java.util.List fillArguments(java.util.List arguments)
          Fill the arguments taken by the Java compiler
 java.util.List getErrors()
          Return the list of errors generated by this compilation
protected abstract  java.util.List parseStream(java.io.BufferedReader errors)
          Parse the compiler error stream to produce a list of CompilerErrors
 void recycle()
          Reset all internal state.
 void setClasspath(java.lang.String classpath)
          Set the classpath to be used for this compilation
 void setDestination(java.lang.String destDir)
          Set the name of the directory to contain the resulting object program file
 void setEncoding(java.lang.String encoding)
          Set the encoding of the input source file or null to use the platform's default encoding
 void setFile(java.lang.String file)
          Set the name of the file containing the source program
 void setSource(java.lang.String srcDir)
          Set the name of the directory containing the source program file
protected  java.lang.String[] toStringArray(java.util.List arguments)
          Copy arguments to a string array
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLoggable
getLogger, setLogger, 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 java.lang.String file
The source program filename

srcDir

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

destDir

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

classpath

protected java.lang.String classpath
The classpath to be used for compilation

encoding

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

errors

protected java.io.InputStream errors
The input stream to output compilation errors
Constructor Detail

AbstractJavaCompiler

public AbstractJavaCompiler()
Method Detail

setFile

public void setFile(java.lang.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(java.lang.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(java.lang.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(java.lang.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(java.lang.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

getErrors

public java.util.List getErrors()
                         throws java.io.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:
java.io.IOException - If an error occurs during message collection

parseStream

protected abstract java.util.List parseStream(java.io.BufferedReader errors)
                                       throws java.io.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:
java.io.IOException - If an error occurs during message collection

fillArguments

protected java.util.List fillArguments(java.util.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 java.lang.String[] toStringArray(java.util.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 org.apache.avalon.excalibur.pool.Recyclable


Copyright © 1999-2002 Apache Software Foundation. All Rights Reserved.