You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by tc...@apache.org on 2005/11/11 01:15:59 UTC
svn commit: r332406 -
/jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/JavaCompilerFactory.java
Author: tcurdt
Date: Thu Nov 10 16:15:55 2005
New Revision: 332406
URL: http://svn.apache.org/viewcvs?rev=332406&view=rev
Log:
a simple factory implementation
Modified:
jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/JavaCompilerFactory.java
Modified: jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/JavaCompilerFactory.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/JavaCompilerFactory.java?rev=332406&r1=332405&r2=332406&view=diff
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/JavaCompilerFactory.java (original)
+++ jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/JavaCompilerFactory.java Thu Nov 10 16:15:55 2005
@@ -15,8 +15,66 @@
*/
package org.apache.commons.jci.compilers;
-public interface JavaCompilerFactory {
-
- JavaCompiler createCompiler(final Object pHint);
+import org.apache.commons.jci.compilers.eclipse.EclipseJavaCompiler;
+import org.apache.commons.jci.compilers.groovy.GroovyJavaCompiler;
+import org.apache.commons.jci.compilers.janino.JaninoJavaCompiler;
-}
+public final class JavaCompilerFactory {
+
+ public static final int ECLIPSE = 0;
+ public static final int JANINO = 1;
+ public static final int GROOVY = 2;
+
+ private static final JavaCompilerFactory INSTANCE = new JavaCompilerFactory();
+
+ public static JavaCompilerFactory getInstance() {
+ return JavaCompilerFactory.INSTANCE;
+ }
+
+ private JavaCompilerFactory() {
+ }
+
+ /**
+ * 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 createCompiler(final String pHint) {
+ if ("eclipse".equalsIgnoreCase(pHint)) {
+ return createCompiler(ECLIPSE);
+ }
+ if ("janino".equalsIgnoreCase(pHint)) {
+ return createCompiler(JANINO);
+ }
+ if ("groovy".equalsIgnoreCase(pHint)) {
+ return createCompiler(GROOVY);
+ }
+
+ return null;
+ }
+
+ /**
+ * Can accept the following ints
+ * JavaCompilerFactory.ECLIPSE
+ * JavaCompilerFactory.JANINO
+ * JavaCompilerFactory.GROOVY
+ * and returns the appropriate JavaCompiler. Return null for any other int.
+ *
+ * @param compiler
+ * @return
+ */
+ public JavaCompiler createCompiler(final int pCompiler) {
+ switch (pCompiler) {
+ case ECLIPSE:
+ return new EclipseJavaCompiler();
+ case JANINO:
+ return new JaninoJavaCompiler();
+ case GROOVY:
+ return new GroovyJavaCompiler();
+ default:
+ return null;
+ }
+ }
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org