KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > jpdl > xml > Problem


1 package org.jbpm.jpdl.xml;
2
3 import java.io.Serializable JavaDoc;
4 import java.util.Collection JavaDoc;
5 import java.util.Iterator JavaDoc;
6
7 public class Problem implements Serializable JavaDoc {
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 JavaDoc 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 JavaDoc description;
26   protected String JavaDoc resource;
27   protected String JavaDoc folder;
28   protected Integer JavaDoc line;
29   protected Throwable JavaDoc exception;
30   
31   public Problem(int level, String JavaDoc description) {
32     this.level = level;
33     this.description = description;
34   }
35
36   public Problem(int level, String JavaDoc description, Throwable JavaDoc exception) {
37     this.level = level;
38     this.description = description;
39     this.exception = exception;
40   }
41   
42   public String JavaDoc toString() {
43     StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
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 JavaDoc c, int level) {
53     Iterator JavaDoc 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 JavaDoc getDescription() {
64     return description;
65   }
66   public void setDescription(String JavaDoc description) {
67     this.description = description;
68   }
69   public Throwable JavaDoc getException() {
70     return exception;
71   }
72   public void setException(Throwable JavaDoc exception) {
73     this.exception = exception;
74   }
75   public String JavaDoc getFolder() {
76     return folder;
77   }
78   public void setFolder(String JavaDoc folder) {
79     this.folder = folder;
80   }
81   public Integer JavaDoc getLine() {
82     return line;
83   }
84   public void setLine(Integer JavaDoc line) {
85     this.line = line;
86   }
87   public String JavaDoc getResource() {
88     return resource;
89   }
90   public void setResource(String JavaDoc resource) {
91     this.resource = resource;
92   }
93   public int getLevel() {
94     return level;
95   }
96 }
97
Popular Tags