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 1.0
026 * @version $Id: TrueFileFilter.java 1304058 2012-03-22 21:02:43Z sebb $
027 * @see FileFilterUtils#trueFileFilter()
028 */
029 public class TrueFileFilter implements IOFileFilter, Serializable {
030
031 /**
032 * Singleton instance of true filter.
033 * @since 1.3
034 */
035 public static final IOFileFilter TRUE = new TrueFileFilter();
036 /**
037 * Singleton instance of true filter.
038 * Please use the identical TrueFileFilter.TRUE constant.
039 * The new name is more JDK 1.5 friendly as it doesn't clash with other
040 * values when using static imports.
041 */
042 public static final IOFileFilter INSTANCE = TRUE;
043
044 /**
045 * Restrictive consructor.
046 */
047 protected TrueFileFilter() {
048 }
049
050 /**
051 * Returns true.
052 *
053 * @param file the file to check (ignored)
054 * @return true
055 */
056 public boolean accept(File file) {
057 return true;
058 }
059
060 /**
061 * Returns true.
062 *
063 * @param dir the directory to check (ignored)
064 * @param name the filename (ignored)
065 * @return true
066 */
067 public boolean accept(File dir, String name) {
068 return true;
069 }
070
071 }