1 package org.jbpm.jpdl.xml; 2 3 import java.io.Serializable ; 4 import java.util.Collection ; 5 import java.util.Iterator ; 6 7 public class Problem implements Serializable { 8 9 private static final long serialVersionUID = 1L; 10 11 public static final int LEVEL_FATAL = 1; 12 public static final int LEVEL_ERROR = 2; 13 public static final int LEVEL_WARNING = 3; 14 public static final int LEVEL_INFO = 4; 15 16 private static String getTypeDescription(int level) { 17 if (level==LEVEL_FATAL) return "FATAL"; 18 if (level==LEVEL_ERROR) return "ERROR"; 19 if (level==LEVEL_WARNING) return "WARNING"; 20 if (level==LEVEL_INFO) return "INFO"; 21 return null; 22 } 23 24 protected int level; 25 protected String description; 26 protected String resource; 27 protected String folder; 28 protected Integer line; 29 protected Throwable exception; 30 31 public Problem(int level, String description) { 32 this.level = level; 33 this.description = description; 34 } 35 36 public Problem(int level, String description, Throwable exception) { 37 this.level = level; 38 this.description = description; 39 this.exception = exception; 40 } 41 42 public String toString() { 43 StringBuffer buffer = new StringBuffer (); 44 buffer.append("["+getTypeDescription(level)+"]"); 45 if (resource!=null) buffer.append(" "+resource); 46 if (line!=null) buffer.append("("+line+")"); 47 if (folder!=null) buffer.append(" "+folder); 48 if (description!=null) buffer.append(" "+description); 49 return buffer.toString(); 50 } 51 52 public static boolean containsProblemsOfLevel(Collection c, int level) { 53 Iterator iter = c.iterator(); 54 while (iter.hasNext()) { 55 Problem problem = (Problem) iter.next(); 56 if (problem.level <= level) { 57 return true; 58 } 59 } 60 return false; 61 } 62 63 public String getDescription() { 64 return description; 65 } 66 public void setDescription(String description) { 67 this.description = description; 68 } 69 public Throwable getException() { 70 return exception; 71 } 72 public void setException(Throwable exception) { 73 this.exception = exception; 74 } 75 public String getFolder() { 76 return folder; 77 } 78 public void setFolder(String folder) { 79 this.folder = folder; 80 } 81 public Integer getLine() { 82 return line; 83 } 84 public void setLine(Integer line) { 85 this.line = line; 86 } 87 public String getResource() { 88 return resource; 89 } 90 public void setResource(String resource) { 91 this.resource = resource; 92 } 93 public int getLevel() { 94 return level; 95 } 96 } 97 | Popular Tags |