001: /*
002: * JBoss, Home of Professional Open Source
003: * Copyright 2005, JBoss Inc., and individual contributors as indicated
004: * by the @authors tag. See the copyright.txt in the distribution for a
005: * full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jbpm.jpdl.xml;
023:
024: import java.io.Serializable;
025: import java.util.Collection;
026: import java.util.Iterator;
027:
028: public class Problem implements Serializable {
029:
030: private static final long serialVersionUID = 1L;
031:
032: public static final int LEVEL_FATAL = 1;
033: public static final int LEVEL_ERROR = 2;
034: public static final int LEVEL_WARNING = 3;
035: public static final int LEVEL_INFO = 4;
036:
037: static String getTypeDescription(int level) {
038: if (level == LEVEL_FATAL)
039: return "FATAL";
040: if (level == LEVEL_ERROR)
041: return "ERROR";
042: if (level == LEVEL_WARNING)
043: return "WARNING";
044: if (level == LEVEL_INFO)
045: return "INFO";
046: return null;
047: }
048:
049: protected int level;
050: protected String description;
051: protected String resource;
052: protected String folder;
053: protected Integer line;
054: protected Throwable exception;
055:
056: public Problem(int level, String description) {
057: this .level = level;
058: this .description = description;
059: }
060:
061: public Problem(int level, String description, Throwable exception) {
062: this .level = level;
063: this .description = description;
064: this .exception = exception;
065: }
066:
067: public String toString() {
068: StringBuffer buffer = new StringBuffer();
069: buffer.append("[" + getTypeDescription(level) + "]");
070: if (resource != null)
071: buffer.append(" " + resource);
072: if (line != null)
073: buffer.append("(" + line + ")");
074: if (folder != null)
075: buffer.append(" " + folder);
076: if (description != null)
077: buffer.append(" " + description);
078: return buffer.toString();
079: }
080:
081: public static boolean containsProblemsOfLevel(Collection c,
082: int level) {
083: Iterator iter = c.iterator();
084: while (iter.hasNext()) {
085: Problem problem = (Problem) iter.next();
086: if (problem.level <= level) {
087: return true;
088: }
089: }
090: return false;
091: }
092:
093: public String getDescription() {
094: return description;
095: }
096:
097: public void setDescription(String description) {
098: this .description = description;
099: }
100:
101: public Throwable getException() {
102: return exception;
103: }
104:
105: public void setException(Throwable exception) {
106: this .exception = exception;
107: }
108:
109: public String getFolder() {
110: return folder;
111: }
112:
113: public void setFolder(String folder) {
114: this .folder = folder;
115: }
116:
117: public Integer getLine() {
118: return line;
119: }
120:
121: public void setLine(Integer line) {
122: this .line = line;
123: }
124:
125: public String getResource() {
126: return resource;
127: }
128:
129: public void setResource(String resource) {
130: this .resource = resource;
131: }
132:
133: public int getLevel() {
134: return level;
135: }
136: }
|