KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > validator > ValidationContext


1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17 package org.apache.geronimo.validator;
18
19 import java.util.*;
20
21 public class ValidationContext {
22     
23     protected ArrayList failures = new ArrayList();
24     protected ArrayList warnings = new ArrayList();
25     protected ArrayList errors = new ArrayList();
26
27     protected Map attributes = new HashMap();
28
29     protected String JavaDoc jarPath;
30     
31     public ValidationContext(String JavaDoc name){
32         this.jarPath = name;
33     }
34
35     public Set entrySet() {
36         return attributes.entrySet();
37     }
38
39     public Object JavaDoc remove(Object JavaDoc key) {
40         return attributes.remove(key);
41     }
42
43     public Object JavaDoc put(Object JavaDoc key, Object JavaDoc value) {
44         return attributes.put(key, value);
45     }
46
47     public Object JavaDoc get(Object JavaDoc key) {
48         return attributes.get(key);
49     }
50
51     public boolean containsKey(Object JavaDoc key) {
52         return attributes.containsKey(key);
53     }
54
55     public void addWarning( ValidationWarning warning ) {
56         warnings.add( warning );
57     }
58     
59     public void addFailure(ValidationFailure failure) {
60         failures.add( failure );
61     }
62
63     public void addError(ValidationError error) {
64         errors.add( error );
65     }
66
67     public ValidationFailure[] getFailures() {
68         return (ValidationFailure[])failures.toArray(new ValidationFailure[0]);
69     }
70     
71     public ValidationWarning[] getWarnings() {
72         return (ValidationWarning[])failures.toArray(new ValidationWarning[0]);
73     }
74     
75     public ValidationError[] getErrors() {
76         return (ValidationError[])failures.toArray(new ValidationError[0]);
77     }
78
79     public boolean hasWarnings(){
80         return warnings.size() > 0;
81     }
82
83     public boolean hasFailures(){
84         return failures.size() > 0;
85     }
86     
87     public boolean hasErrors(){
88         return errors.size() > 0;
89     }
90 }
91
Popular Tags