Clover Coverage Report - KS Common 1.3.0-SNAPSHOT (Aggregated)
Coverage timestamp: Thu Apr 28 2011 06:00:36 EDT
../../../../../../img/srcFileCovDistChart0.png 0% of files have more coverage
26   176   22   1.3
4   86   0.85   10
20     1.1  
2    
 
  ValidationResultInfo       Line # 25 22 0% 16 38 0% 0.0
  ValidationResultInfo.ErrorLevel       Line # 29 4 0% 6 12 0% 0.0
 
No Tests
 
1    /**
2    * Copyright 2010 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10    * software distributed under the License is distributed on an "AS IS"
11    * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12    * or implied. See the License for the specific language governing
13    * permissions and limitations under the License.
14    */
15   
16    package org.kuali.student.common.validation.dto;
17   
18    import java.io.Serializable;
19   
20    import javax.xml.bind.annotation.XmlAccessType;
21    import javax.xml.bind.annotation.XmlAccessorType;
22    import javax.xml.bind.annotation.XmlElement;
23   
24    @XmlAccessorType(XmlAccessType.FIELD)
 
25    public class ValidationResultInfo implements Serializable{
26   
27    private static final long serialVersionUID = 1L;
28   
 
29    public enum ErrorLevel {
30    OK(0), WARN(1), ERROR(2);
31   
32    int level;
33   
 
34  0 toggle private ErrorLevel(int level) {
35  0 this.level = level;
36    }
37   
 
38  0 toggle public int getLevel() {
39  0 return level;
40    }
41   
 
42  0 toggle public static ErrorLevel min(ErrorLevel e1, ErrorLevel e2) {
43  0 return e1.ordinal() < e2.ordinal() ? e1 : e2;
44    }
 
45  0 toggle public static ErrorLevel max(ErrorLevel e1, ErrorLevel e2) {
46  0 return e1.ordinal() > e2.ordinal() ? e1 : e2;
47    }
48    }
49   
 
50  0 toggle public ValidationResultInfo() {
51  0 super();
52  0 this.level = ErrorLevel.OK;
53    }
54   
55    private transient Object invalidData = null;
56   
 
57  0 toggle public ValidationResultInfo(String element) {
58  0 super();
59  0 this.level = ErrorLevel.OK;
60  0 this.element = element;
61    }
62   
 
63  0 toggle public ValidationResultInfo(String element, Object invalidData) {
64  0 this(element);
65  0 this.invalidData = invalidData;
66    }
67   
68   
69    @XmlElement
70    protected String element;
71   
72    @XmlElement
73    protected ErrorLevel level = ErrorLevel.OK;
74   
75    @XmlElement
76    protected String message;
77   
78    /**
79    * @return the level
80    */
 
81  0 toggle public ErrorLevel getLevel() {
82  0 return level;
83    }
84   
85    /**
86    * @param level the level to set
87    */
 
88  0 toggle public void setLevel(ErrorLevel level) {
89  0 this.level = level;
90    }
91   
92    /**
93    * @return the message
94    */
 
95  0 toggle public String getMessage() {
96  0 return message;
97    }
98   
99    /**
100    * @param message the message to set
101    */
 
102  0 toggle public void setMessage(String message) {
103  0 this.message = message;
104    }
105   
 
106  0 toggle public String getElement() {
107  0 return element;
108    }
109   
 
110  0 toggle public void setElement(String element) {
111  0 this.element = element;
112    }
113   
114    /**
115    * Returns the ValidationResult's error level
116    *
117    * @return
118    */
 
119  0 toggle public ErrorLevel getErrorLevel() {
120  0 return level;
121    }
122   
123    /**
124    * Convenience method. Adds a message with an error level of WARN
125    *
126    * @param message
127    * the message to add
128    */
 
129  0 toggle public void setWarning(String message) {
130  0 this.level = ErrorLevel.WARN;
131  0 this.message = message;
132    }
133   
134    /**
135    * Convenience method. Adds a message with an error level of ERROR
136    *
137    * @param message
138    * the message to add
139    */
 
140  0 toggle public void setError(String message) {
141  0 this.level = ErrorLevel.ERROR;
142  0 this.message = message;
143    }
144   
145    /**
146    * Convenience method. Returns true if getErrorLevel() == ErrorLevel.OK
147    *
148    * @return true if getErrorLevel() == ErrorLevel.OK
149    */
 
150  0 toggle public boolean isOk() {
151  0 return getErrorLevel() == ErrorLevel.OK;
152    }
153   
154    /**
155    * Convenience method. Returns true if getErrorLevel() == ErrorLevel.WARN
156    *
157    * @return true if getErrorLevel() == ErrorLevel.WARN
158    */
 
159  0 toggle public boolean isWarn() {
160  0 return getErrorLevel() == ErrorLevel.WARN;
161    }
162   
163    /**
164    * Convenience method. Returns true if getErrorLevel() == ErrorLevel.ERROR
165    *
166    * @return true if getErrorLevel() == ErrorLevel.ERROR
167    */
 
168  0 toggle public boolean isError() {
169  0 return getErrorLevel() == ErrorLevel.ERROR;
170    }
171   
 
172  0 toggle public String toString(){
173  0 return "[" + level + "] Path: [" + element + "] - " + message + " data=[" + invalidData + "]";
174    }
175   
176    }