DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGĀ·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=37409>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDĀ·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=37409





------- Additional Comments From [EMAIL PROTECTED]  2005-11-08 18:52 -------
package org.apache.commons.jci;

import org.apache.commons.jci.compilers.JavaCompiler;
import org.apache.commons.jci.compilers.eclipse.EclipseJavaCompiler;
import org.apache.commons.jci.compilers.groovy.GroovyJavaCompiler;
import org.apache.commons.jci.compilers.janino.JaninoJavaCompiler;

/**
 * Simple Compiler Factory that returns an instance of a JavaCompiler for the
requested type.
 * 
 * @author mproctor
 *
 */
public class CompilerFactory
{
    public static final int ECLIPSE = 0;
    public static final int JANINO = 1;
    public static final int GROOVY = 2;
    
    private static final CompilerFactory INSTANCE = new CompilerFactory();
    
    public static CompilerFactory getInstance() {
        return CompilerFactory.INSTANCE;
    }
    
    private CompilerFactory() {
        
    }
    
    /**
     * Can accept the following strings "ECLIPSE", "JANINO", "GROOVY" and
returns the appropriate
     * JavaCompiler. Return null for any other type of string.
     * 
     * @param compiler
     * @return
     */
    public JavaCompiler newCompiler(String compiler) {
        JavaCompiler javaCompiler = null;
        int i = -1;
        if ( compiler.equals("ECLIPSE") ) {
            javaCompiler = newCompiler( ECLIPSE );
        } else if ( compiler.equals("JANINO") ) {
            javaCompiler = newCompiler( JANINO );
        } else if ( compiler.equals("GROOVY") ) {
            javaCompiler = newCompiler( GROOVY );
        } 
    
        return javaCompiler;                       
    }
    
    /**
     * Can accept the following ints CompilerFactory.ECLIPSE
CompilerFactory.JANINO CompilerFactory.GROOVY 
     * and returns the appropriate JavaCompiler. Return null for any other int.
     * 
     * @param compiler
     * @return
     */    
    public JavaCompiler newCompiler(int compiler) {
        JavaCompiler javaCompiler = null;
        switch ( compiler ) {
            case ECLIPSE:
                javaCompiler = new EclipseJavaCompiler();
                break;
            case JANINO:
                javaCompiler = new JaninoJavaCompiler();
                break;
            case GROOVY:
                javaCompiler = new GroovyJavaCompiler();
                break;                  
        }
        
        return javaCompiler;
    }        
}


-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to