1 16 17 package org.apache.axis.components.compiler; 18 19 import java.io.BufferedReader ; 20 import java.io.IOException ; 21 import java.io.InputStream ; 22 import java.io.InputStreamReader ; 23 import java.util.ArrayList ; 24 import java.util.List ; 25 26 32 public abstract class AbstractCompiler implements Compiler { 33 34 37 protected ArrayList fileList = new ArrayList (); 38 39 42 protected String srcDir; 43 44 47 protected String destDir; 48 49 52 protected String classpath; 53 54 58 protected String encoding = null; 59 60 63 protected InputStream errors; 64 65 70 public void addFile(String file) { 71 this.fileList.add(file); 72 } 73 74 79 public void setSource(String srcDir) { 80 this.srcDir = srcDir; 81 } 82 83 89 public void setDestination(String destDir) { 90 this.destDir = destDir; 91 } 92 93 98 public void setClasspath(String classpath) { 99 this.classpath = classpath; 100 } 101 102 109 public void setEncoding(String encoding) { 110 this.encoding = encoding; 111 } 112 113 119 public List getErrors() throws IOException { 120 return parseStream(new BufferedReader (new InputStreamReader (errors))); 121 } 122 123 131 protected abstract List parseStream(BufferedReader errors) 132 throws IOException ; 133 134 140 protected List fillArguments(List arguments) { 141 arguments.add("-d"); 143 arguments.add(destDir); 144 145 arguments.add("-classpath"); 147 arguments.add(classpath); 148 149 if(srcDir != null) { 151 arguments.add("-sourcepath"); 152 arguments.add(srcDir); 153 } 154 155 arguments.add("-O"); 157 158 arguments.add("-g"); 160 161 if (encoding != null) { 163 arguments.add("-encoding"); 164 arguments.add(encoding); 165 } 166 167 return arguments; 168 } 169 170 176 protected String [] toStringArray(List arguments) { 177 int i; 178 String [] args = new String [arguments.size() + fileList.size()]; 179 180 for (i = 0; i < arguments.size(); i++) { 181 args[i] = (String ) arguments.get(i); 182 } 183 184 for (int j=0; j < fileList.size(); i++,j++) { 185 args[i] = (String )fileList.get(j); 186 } 187 return args; 188 } 189 } 190 | Popular Tags |