1 package org.ozoneDB.tools.OPP.compiler; 9 10 import java.io.File ; 11 import java.util.Collection ; 12 import java.util.List ; 13 import java.util.ArrayList ; 14 import java.util.Iterator ; 15 16 22 public abstract class AbstractJavaCompiler implements JavaCompiler { 23 private String classpath; 24 private boolean optimize; 25 private boolean debug; 26 private boolean noWarn; 27 private boolean deprecation; 28 private File sourcePath; 29 private File outputPath; 30 31 public File getOutputPath() { 32 return outputPath; 33 } 34 35 public void setOutputPath(File outputPath) { 36 this.outputPath = outputPath; 37 } 38 39 public boolean isOptimize() { 40 return optimize; 41 } 42 43 public void setOptimize(boolean optimize) { 44 this.optimize = optimize; 45 } 46 47 public boolean isDebug() { 48 return debug; 49 } 50 51 public void setDebug(boolean debug) { 52 this.debug = debug; 53 } 54 55 public boolean isNoWarn() { 56 return noWarn; 57 } 58 59 public void setNoWarn(boolean noWarn) { 60 this.noWarn = noWarn; 61 } 62 63 public boolean isDeprecation() { 64 return deprecation; 65 } 66 67 public void setDeprecation(boolean deprecation) { 68 this.deprecation = deprecation; 69 } 70 71 public File getSourcePath() { 72 return sourcePath; 73 } 74 75 public void setSourcePath(File sourcePath) { 76 this.sourcePath = sourcePath; 77 } 78 79 public String getClasspath() { 80 return classpath; 81 } 82 83 public void setClasspath(String classpath) { 84 this.classpath = classpath; 85 } 86 87 protected String [] getArguments(Collection classes) { 88 return getArguments(null, classes); 89 } 90 91 97 protected String [] getArguments(String command, Collection classes) { 98 List arguments = new ArrayList (classes.size() + 10); 99 if (command != null) { 100 arguments.add(command); 101 } 102 if (classpath != null) { 103 arguments.add("-classpath"); 104 arguments.add(getClasspath()); 105 } 106 if (optimize) { 107 arguments.add("-O"); 108 } 109 if (debug) { 110 arguments.add("-g"); 111 } else { 112 arguments.add("-g:none"); 113 } 114 if (noWarn) { 115 arguments.add("-noWarn"); 116 } 117 if (deprecation) { 118 arguments.add("-deprecation"); 119 } 120 if (sourcePath != null) { 121 arguments.add("-sourcepath"); 122 arguments.add(sourcePath.toString()); 123 } 125 if (outputPath != null) { 126 arguments.add("-d"); 127 arguments.add(outputPath.toString()); 128 } 130 arguments.addAll(classes); 131 String retArgs[] = new String [arguments.size()]; 132 int i = 0; 133 for (Iterator iter = arguments.iterator(); iter.hasNext(); i++) { 134 retArgs[i] = (String ) iter.next(); 135 } 137 return retArgs; 138 } 139 } 140 | Popular Tags |