1 4 5 9 10 package org.openlaszlo.compiler; 11 import org.jdom.Element; 12 import org.openlaszlo.utils.ChainedException; 13 import java.lang.Integer ; 14 import java.io.*; 15 import java.util.*; 16 import org.openlaszlo.server.*; 17 import org.openlaszlo.utils.*; 18 import org.openlaszlo.xml.internal.*; 19 20 24 public class CompilationErrorHandler { 25 26 private List errors = new Vector(); 27 protected String fileBase = ""; 28 29 public CompilationErrorHandler() { 30 } 31 32 34 public void setFileBase(String fileBase) { 35 this.fileBase = fileBase; 36 } 37 38 41 void addError(CompilationError e) { 42 e.setFileBase(fileBase); 43 errors.add(e); 44 } 45 46 49 public List getErrors() 50 { 51 return errors; 52 } 53 54 56 public int size() 57 { 58 return errors.size(); 59 } 60 61 public boolean isEmpty() { 62 return errors.isEmpty(); 63 } 64 65 69 public void appendErrors(CompilationErrorHandler other) { 70 for (Iterator iter = other.getErrors().iterator(); iter.hasNext(); ) { 71 CompilationError error = (CompilationError) iter.next(); 72 errors.add(error); 73 } 74 } 75 76 79 public CompilationError toCompilationError() { 80 StringBuffer buffer = new StringBuffer (); 81 for (Iterator iter = errors.iterator(); iter.hasNext(); ) { 82 CompilationError error = (CompilationError) iter.next(); 83 buffer.append(error.getMessage()); 84 if (iter.hasNext()) { 85 buffer.append('\n'); 86 } 87 } 88 return new CompilationError(buffer.toString()); 89 } 90 91 public String toXML() { 92 StringBuffer buffer = new StringBuffer (); 93 for (Iterator iter = errors.iterator(); iter.hasNext(); ) { 94 CompilationError error = (CompilationError) iter.next(); 95 buffer.append(error.toXML()); 96 if (iter.hasNext()) { 97 buffer.append("<br/>"); 98 } 99 } 100 return buffer.toString(); 101 } 102 } 103 | Popular Tags |