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.commons.io.filefilter;
018    
019    import java.io.File;
020    import java.io.Serializable;
021    
022    /**
023     * A file filter that always returns true.
024     *
025     * @since Commons IO 1.0
026     * @version $Revision: 587978 $ $Date: 2007-10-24 20:36:51 +0100 (Wed, 24 Oct 2007) $
027     *
028     * @author Stephen Colebourne
029     */
030    public class TrueFileFilter implements IOFileFilter, Serializable {
031    
032        /**
033         * Singleton instance of true filter.
034         * @since Commons IO 1.3
035         */
036        public static final IOFileFilter TRUE = new TrueFileFilter();
037        /**
038         * Singleton instance of true filter.
039         * Please use the identical TrueFileFilter.TRUE constant.
040         * The new name is more JDK 1.5 friendly as it doesn't clash with other
041         * values when using static imports.
042         */
043        public static final IOFileFilter INSTANCE = TRUE;
044    
045        /**
046         * Restrictive consructor.
047         */
048        protected TrueFileFilter() {
049        }
050    
051        /**
052         * Returns true.
053         *
054         * @param file  the file to check
055         * @return true
056         */
057        public boolean accept(File file) {
058            return true;
059        }
060    
061        /**
062         * Returns true.
063         *
064         * @param dir  the directory to check
065         * @param name  the filename
066         * @return true
067         */
068        public boolean accept(File dir, String name) {
069            return true;
070        }
071    
072    }