KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > config > serverbeans > validation > Result


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 package com.sun.enterprise.config.serverbeans.validation;
24
25 import java.util.*;
26 import com.sun.enterprise.util.LocalStringManagerImpl;
27
28 public class Result {
29
30     public static final int PASSED = 0;
31     public static final int FAILED = 1;
32     public static final int WARNING = 2;
33     public static final int NOT_APPLICABLE = 3;
34     public static final int NOT_RUN = 4;
35     public static final int NOT_IMPLEMENTED = 5;
36     private int status = NOT_RUN;
37     private String JavaDoc componentName;
38     private String JavaDoc operationPrintName;
39     private String JavaDoc assertion;
40     private String JavaDoc testName;
41     private Vector errorDetails = new Vector();
42     private Vector goodDetails = new Vector();
43     private Vector warningDetails = new Vector();
44     private Vector naDetails = new Vector();
45     //boolean debug = Verifier.getDebug();
46
boolean debug = false;
47
48     /**
49      * Result Constructor
50      *
51      */

52     public void Result(){
53     }
54
55
56     /**
57      * Store passed info
58      *
59      * @param detail Details of passed test
60      */

61     public void passed(String JavaDoc detail){
62     setStatus(PASSED);
63     addGoodDetails(detail);
64     }
65
66     /**
67      * Store warning info
68      *
69      * @param detail Details of warning test
70      */

71     public void warning(String JavaDoc detail){
72     setStatus(WARNING);
73     addWarningDetails(detail);
74     }
75
76     /**
77      * Store Not Applicable info
78      *
79      * @param detail Details of not applicable test
80      */

81     public void notApplicable(String JavaDoc detail){
82     setStatus(NOT_APPLICABLE);
83     addNaDetails(detail);
84     }
85
86     /**
87      * Store Failed info
88      *
89      * @param detail Details of failed test
90      */

91     public void failed(String JavaDoc detail){
92     setStatus(FAILED);
93     addErrorDetails(detail);
94     }
95
96     /**
97      * Retrieve Not Applicable details
98      *
99      * @return <code>Vector</code> not applicable details
100      */

101     public Vector getNaDetails(){
102     return naDetails;
103     }
104
105     /**
106      * Retrieve Warning details
107      *
108      * @return <code>Vector</code> warning details
109      */

110     public Vector getWarningDetails(){
111     return warningDetails;
112     }
113
114     /**
115      * Set Not Applicable details
116      *
117      * @param s not applicable details
118      */

119     public void addNaDetails(String JavaDoc s){
120     naDetails.addElement(s);
121     }
122
123     /**
124      * Retrieve Good details
125      *
126      * @return <code>Vector</code> good details
127      */

128     public Vector getGoodDetails(){
129     return goodDetails;
130     }
131
132     /**
133      * Fill in Good details
134      *
135      * @param s good detail string
136      */

137     public void addGoodDetails(String JavaDoc s){
138     goodDetails.addElement(s);
139     }
140
141     /**
142      * Fill in Warning details
143      *
144      * @param s warning detail string
145      */

146     public void addWarningDetails(String JavaDoc s){
147     warningDetails.addElement(s);
148     }
149
150     /**
151      * Retrieve Error details
152      *
153      * @return <code>Vector</code> error details
154      */

155     public Vector getErrorDetails(){
156     return errorDetails;
157     }
158
159     /**
160      * Retrieve Error details
161      *
162      * @return <code>Vector</code> error details
163      */

164     public String JavaDoc getErrorDetailsAsString(){
165         String JavaDoc str = "";
166     for(int i=0; i<errorDetails.size(); i++)
167         {
168             if(i>0)
169                 str += "\n";
170             str += errorDetails.get(i);
171         }
172         //add rejection string at the end
173
if(errorDetails.size()>0 &&
174            operationPrintName!=null &&
175            operationPrintName.length()>0)
176         {
177             str += "\n";
178             str += StringManagerHelper.getLocalStringsManager().getLocalString(
179                       "operation_reject_msg","{0} has been rejected.",
180                       new Object JavaDoc[] {operationPrintName});
181                     
182         }
183         return str;
184     }
185
186     /**
187      * Fill in Error details
188      *
189      * @param s error detail string
190      */

191     public void addErrorDetails(String JavaDoc s){
192     errorDetails.addElement(s);
193     }
194
195     /**
196      * Fill in Error details
197      *
198      * @param s error detail string
199      */

200     public void addErrorDetails(int index, String JavaDoc s){
201     errorDetails.add(index, s);
202     }
203
204     /**
205      * Retrieve test result status
206      *
207      * @return <code>int</code> test result status
208      */

209     public int getStatus(){
210     return status;
211     }
212
213     /**
214      * Set test result status
215      *
216      * @param s test result status
217      */

218     public void setStatus(int s){
219     status = s;
220     }
221
222     /**
223      * Retrieve assertion
224      *
225      * @return <code>String</code> assertion string
226      */

227     public String JavaDoc getAssertion(){
228     return assertion;
229     }
230
231     /**
232      * Set assertion
233      *
234      * @param s assertion string
235      */

236     public void setAssertion(String JavaDoc s){
237     assertion = s;
238     }
239
240     /**
241      * Retrieve component/module name
242      *
243      * @return <code>String</code> component/module name
244      */

245     public String JavaDoc getComponentName(){
246     return componentName;
247     }
248
249     /**
250      * Set component/module name
251      *
252      * @param s component/module name
253      */

254     public void setComponentName(String JavaDoc s){
255     componentName = s;
256     }
257
258     /**
259      * Retrieve config operation name
260      *
261      * @return <code>String</code> component/module name
262      */

263     public String JavaDoc getOperationPrintName(){
264     return operationPrintName;
265     }
266
267     /**
268      * Set component/module name
269      *
270      * @param s component/module name
271      */

272     public void setOperationPrintName(String JavaDoc s){
273     operationPrintName = s;
274     }
275
276     /**
277      * Retrieve test name
278      *
279      * @return <code>String</code> test name
280      */

281     public String JavaDoc getTestName(){
282     return testName;
283     }
284
285     /**
286      * Set test name
287      *
288      * @param s test name
289      */

290     public void setTestName(String JavaDoc s){
291     testName = s;
292     }
293
294 } // Result class
295
Popular Tags