001    /**
002     *  Licensed to the Apache Software Foundation (ASF) under one or more
003     *  contributor license agreements.  See the NOTICE file distributed with
004     *  this work for additional information regarding copyright ownership.
005     *  The ASF licenses this file to You under the Apache License, Version 2.0
006     *  (the "License"); you may not use this file except in compliance with
007     *  the License.  You may obtain a copy of the License at
008     *
009     *     http://www.apache.org/licenses/LICENSE-2.0
010     *
011     *  Unless required by applicable law or agreed to in writing, software
012     *  distributed under the License is distributed on an "AS IS" BASIS,
013     *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     *  See the License for the specific language governing permissions and
015     *  limitations under the License.
016     */
017    package org.apache.geronimo.validator;
018    
019    import java.util.*;
020    
021    public class ValidationContext {
022        
023        protected ArrayList failures = new ArrayList();
024        protected ArrayList warnings = new ArrayList();
025        protected ArrayList errors   = new ArrayList();
026    
027        protected Map attributes = new HashMap();
028    
029        protected String jarPath;
030        
031        public ValidationContext(String name){
032            this.jarPath = name;
033        }
034    
035        public Set entrySet() {
036            return attributes.entrySet();
037        }
038    
039        public Object remove(Object key) {
040            return attributes.remove(key);
041        }
042    
043        public Object put(Object key, Object value) {
044            return attributes.put(key, value);
045        }
046    
047        public Object get(Object key) {
048            return attributes.get(key);
049        }
050    
051        public boolean containsKey(Object key) {
052            return attributes.containsKey(key);
053        }
054    
055        public void addWarning( ValidationWarning warning ) {
056            warnings.add( warning );
057        }
058        
059        public void addFailure(ValidationFailure failure) {
060            failures.add( failure );
061        }
062    
063        public void addError(ValidationError error) {
064            errors.add( error );
065        }
066    
067        public ValidationFailure[] getFailures() {
068            return (ValidationFailure[])failures.toArray(new ValidationFailure[0]);
069        }
070        
071        public ValidationWarning[] getWarnings() {
072            return (ValidationWarning[])failures.toArray(new ValidationWarning[0]);
073        }
074        
075        public ValidationError[] getErrors() {
076            return (ValidationError[])failures.toArray(new ValidationError[0]);
077        }
078    
079        public boolean hasWarnings(){
080            return warnings.size() > 0;
081        }
082    
083        public boolean hasFailures(){
084            return failures.size() > 0;
085        }
086        
087        public boolean hasErrors(){
088            return errors.size() > 0;
089        }
090    }