KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > ResultManager


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
24 package com.sun.enterprise.tools.verifier;
25
26
27 import java.util.Vector JavaDoc;
28 import java.util.logging.LogRecord JavaDoc;
29
30 /**
31  * This class is responsible for collecting the result and error data
32  *
33  * @author Sudipto Ghosh
34  */

35
36 public class ResultManager {
37
38     public void add(Result result) {
39         Result r = result;
40         addToResult(r);
41     }
42
43     public void log(LogRecord JavaDoc logRecord) {
44         error.add(logRecord);
45     }
46
47     public int getFailedCount() {
48         return (failedResults == null) ? 0 : failedResults.size();
49     }
50
51     public int getWarningCount() {
52         return (warningResults == null) ? 0 : warningResults.size();
53     }
54
55     public int getErrorCount() {
56         return (error == null) ? 0 : error.size();
57     }
58
59     public Vector JavaDoc getFailedResults() {
60         return failedResults;
61     }
62
63     public Vector JavaDoc getOkayResults() {
64         return okayResults;
65     }
66
67     public Vector JavaDoc getWarningResults() {
68         return warningResults;
69     }
70
71     public Vector JavaDoc getNaResults() {
72         return naResults;
73     }
74
75     public Vector JavaDoc getError() {
76         return error;
77     }
78
79     /**
80      * add the result object to specific Vector based on the status.
81      *
82      * @param r
83      */

84     private void addToResult(Result r) {
85         if (r.getStatus() == Result.FAILED) {
86             failedResults.add(r);
87         } else if (r.getStatus() == Result.PASSED) {
88             okayResults.add(r);
89         } else if (r.getStatus() == Result.WARNING) {
90             warningResults.add(r);
91         } else if ((r.getStatus() == Result.NOT_APPLICABLE) ||
92                 (r.getStatus() == Result.NOT_RUN) ||
93                 (r.getStatus() == Result.NOT_IMPLEMENTED)) {
94             naResults.add(r);
95         }
96     }
97
98     private Vector JavaDoc<Result> failedResults = new Vector JavaDoc<Result>();
99     private Vector JavaDoc<Result> okayResults = new Vector JavaDoc<Result>();
100     private Vector JavaDoc<Result> warningResults = new Vector JavaDoc<Result>();
101     private Vector JavaDoc<Result> naResults = new Vector JavaDoc<Result>();
102     private Vector JavaDoc<LogRecord JavaDoc> error = new Vector JavaDoc<LogRecord JavaDoc>();
103 }
104
Popular Tags