View Javadoc

1   /**
2    * Copyright 2005 Steve Molloy
3    * 
4    * This file is part of OV4J.
5    * 
6    * OV4J is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as
7    * published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
8    * 
9    * OV4J is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
10   * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
11   * 
12   * You should have received a copy of the GNU General Public License along with OV4J; if not, write to the Free Software
13   * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
14   * 
15   */
16  package org.ov4j.hessianImpl;
17  
18  import java.util.logging.Level;
19  import java.util.logging.Logger;
20  
21  import java.io.File;
22  import java.io.FileFilter;
23  
24  /**
25   * @author smolloy
26   * 
27   */
28  public class StdFileFilter implements FileFilter {
29  	/**
30  	 * Logger for this class
31  	 */
32  	private static final Logger	logger	= Logger.getLogger(StdFileFilter.class.getName());
33  
34  	private final String		ext;
35  
36  	public StdFileFilter() {
37  		ext = null;
38  	}
39  
40  	public StdFileFilter(final String ext) {
41  		this.ext = ext;
42  	}
43  
44  	/**
45  	 * Accepts only normal files.
46  	 * 
47  	 * @see java.io.FileFilter#accept(java.io.File)
48  	 */
49  	public boolean accept(final File pathname) {
50  		if (StdFileFilter.logger.isLoggable(Level.FINEST)) {
51  			StdFileFilter.logger.entering("StdFileFilter", "accept(File=" + pathname + ")", "start");
52  		}
53  
54  		if (ext == null) {
55  			final boolean returnboolean = pathname.isFile();
56  
57  			if (StdFileFilter.logger.isLoggable(Level.FINEST)) {
58  				StdFileFilter.logger.exiting("StdFileFilter", "accept(File=" + pathname + ")", "end - return value="
59  					+ returnboolean);
60  			}
61  			return returnboolean;
62  		} else {
63  			final boolean returnboolean = pathname.isFile() && pathname.getName().endsWith(ext);
64  
65  			if (StdFileFilter.logger.isLoggable(Level.FINEST)) {
66  				StdFileFilter.logger.exiting("StdFileFilter", "accept(File=" + pathname + ")", "end - return value="
67  					+ returnboolean);
68  			}
69  			return returnboolean;
70  		}
71  	}
72  
73  }