01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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: */package org.apache.geronimo.validator;
17:
18: import java.util.*;
19:
20: public class ValidationContext {
21:
22: protected ArrayList failures = new ArrayList();
23: protected ArrayList warnings = new ArrayList();
24: protected ArrayList errors = new ArrayList();
25:
26: protected Map attributes = new HashMap();
27:
28: protected String jarPath;
29:
30: public ValidationContext(String name) {
31: this .jarPath = name;
32: }
33:
34: public Set entrySet() {
35: return attributes.entrySet();
36: }
37:
38: public Object remove(Object key) {
39: return attributes.remove(key);
40: }
41:
42: public Object put(Object key, Object value) {
43: return attributes.put(key, value);
44: }
45:
46: public Object get(Object key) {
47: return attributes.get(key);
48: }
49:
50: public boolean containsKey(Object key) {
51: return attributes.containsKey(key);
52: }
53:
54: public void addWarning(ValidationWarning warning) {
55: warnings.add(warning);
56: }
57:
58: public void addFailure(ValidationFailure failure) {
59: failures.add(failure);
60: }
61:
62: public void addError(ValidationError error) {
63: errors.add(error);
64: }
65:
66: public ValidationFailure[] getFailures() {
67: return (ValidationFailure[]) failures
68: .toArray(new ValidationFailure[0]);
69: }
70:
71: public ValidationWarning[] getWarnings() {
72: return (ValidationWarning[]) failures
73: .toArray(new ValidationWarning[0]);
74: }
75:
76: public ValidationError[] getErrors() {
77: return (ValidationError[]) failures
78: .toArray(new ValidationError[0]);
79: }
80:
81: public boolean hasWarnings() {
82: return warnings.size() > 0;
83: }
84:
85: public boolean hasFailures() {
86: return failures.size() > 0;
87: }
88:
89: public boolean hasErrors() {
90: return errors.size() > 0;
91: }
92: }
|