List of usage examples for org.apache.commons.jci.problems CompilationProblem getFileName
String getFileName();
From source file:org.drools.compiler.PackageBuilder.java
/** * This actually triggers the compiling of all the resources. * Errors are mapped back to the element that originally generated the semantic * code.//from w w w . j a v a 2s. co m */ private void compileAll() { String[] classes = new String[this.generatedClassList.size()]; this.generatedClassList.toArray(classes); //byte[] byteArray = src.getBytes(classes[0].replace('.', '/')+".java"); //String str = new String(byteArray); //System.out.println(str); //byte[] byteArray = src.getBytes(classes[0].replace('.','/')+".java"); //String fileContents = new String(byteArray); final CompilationResult result = this.compiler.compile(classes, src, this.packageStoreWrapper, this.pkg.getPackageCompilationData().getClassLoader()); //this will sort out the errors based on what class/file they happened in if (result.getErrors().length > 0) { for (int i = 0; i < result.getErrors().length; i++) { CompilationProblem err = result.getErrors()[i]; ErrorHandler handler = (ErrorHandler) this.errorHandlers.get(err.getFileName()); handler.addError(err); } Collection errors = this.errorHandlers.values(); for (Iterator iter = errors.iterator(); iter.hasNext();) { ErrorHandler handler = (ErrorHandler) iter.next(); if (!(handler instanceof RuleInvokerErrorHandler)) { this.results.add(handler.getError()); } else { //we don't really want to report invoker errors. //mostly as they can happen when there is a syntax error in the RHS //and otherwise, it is a programmatic error in drools itself. System.err.println("!!!! An error occurred compiling the invoker: " + handler.getError()); } } } }