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: 1005099 $ $Date: 2010-10-06 12:13:01 -0400 (Wed, 06 Oct 2010) $
027     *
028     * @author Stephen Colebourne
029     * @see FileFilterUtils#trueFileFilter()
030     */
031    public class TrueFileFilter implements IOFileFilter, Serializable {
032    
033        /**
034         * Singleton instance of true filter.
035         * @since Commons IO 1.3
036         */
037        public static final IOFileFilter TRUE = new TrueFileFilter();
038        /**
039         * Singleton instance of true filter.
040         * Please use the identical TrueFileFilter.TRUE constant.
041         * The new name is more JDK 1.5 friendly as it doesn't clash with other
042         * values when using static imports.
043         */
044        public static final IOFileFilter INSTANCE = TRUE;
045    
046        /**
047         * Restrictive consructor.
048         */
049        protected TrueFileFilter() {
050        }
051    
052        /**
053         * Returns true.
054         *
055         * @param file  the file to check
056         * @return true
057         */
058        public boolean accept(File file) {
059            return true;
060        }
061    
062        /**
063         * Returns true.
064         *
065         * @param dir  the directory to check
066         * @param name  the filename
067         * @return true
068         */
069        public boolean accept(File dir, String name) {
070            return true;
071        }
072    
073    }