001    package org.apache.fulcrum.intake.validator;
002    
003    /*
004     * Licensed to the Apache Software Foundation (ASF) under one
005     * or more contributor license agreements.  See the NOTICE file
006     * distributed with this work for additional information
007     * regarding copyright ownership.  The ASF licenses this file
008     * to you under the Apache License, Version 2.0 (the
009     * "License"); you may not use this file except in compliance
010     * with the License.  You may obtain a copy of the License at
011     *
012     *   http://www.apache.org/licenses/LICENSE-2.0
013     *
014     * Unless required by applicable law or agreed to in writing,
015     * software distributed under the License is distributed on an
016     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017     * KIND, either express or implied.  See the License for the
018     * specific language governing permissions and limitations
019     * under the License.
020     */
021    
022    import java.util.Map;
023    
024    import org.apache.commons.fileupload.FileItem;
025    
026    import org.apache.fulcrum.intake.IntakeException;
027    
028    /**
029     * A validator that will compare a FileItem testValue against the following
030     * constraints in addition to those listed in DefaultValidator.
031     *
032     *
033     *
034     * This validator can serve as the base class for more specific validators
035     *
036     * @author <a href="mailto:jmcnally@collab.net">John McNally</a>
037     * @author <a href="mailto:quintonm@bellsouth.net">Quinton McCombs</a>
038     * @author <a href="mailto:Colin.Chalmers@maxware.nl">Colin Chalmers</a>
039     * @version $Id: FileValidator.java 671324 2008-06-24 20:01:41Z tv $
040     */
041    public class FileValidator
042            extends DefaultValidator
043    {
044    
045        /**
046         *
047         * Constructor
048         *
049         * @param paramMap a <code>Map</code> of <code>rule</code>'s
050         * containing constraints on the input.
051         * @exception InvalidMaskException an invalid mask was specified
052         */
053        public FileValidator(Map paramMap)
054                throws IntakeException
055        {
056            init(paramMap);
057        }
058    
059        /**
060         * Default constructor
061         */
062        public FileValidator()
063        {
064        }
065    
066        /**
067         * Determine whether a testValue meets the criteria specified
068         * in the constraints defined for this validator
069         *
070         * @param testValue a <code>FileItem</code> to be tested
071         * @exception ValidationException containing an error message if the
072         * testValue did not pass the validation tests.
073         */
074        public void assertValidity(FileItem testValue)
075                throws ValidationException
076        {
077            super.assertValidity(testValue.getString());
078        }
079    }