You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by se...@apache.org on 2006/04/08 18:26:30 UTC

svn commit: r392552 - /jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/gui/JMeterFileFilter.java

Author: sebb
Date: Sat Apr  8 09:26:24 2006
New Revision: 392552

URL: http://svn.apache.org/viewcvs?rev=392552&view=rev
Log:
Add option to exclude directories from the filter

Modified:
    jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/gui/JMeterFileFilter.java

Modified: jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/gui/JMeterFileFilter.java
URL: http://svn.apache.org/viewcvs/jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/gui/JMeterFileFilter.java?rev=392552&r1=392551&r2=392552&view=diff
==============================================================================
--- jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/gui/JMeterFileFilter.java (original)
+++ jakarta/jmeter/branches/rel-2-1/src/core/org/apache/jmeter/gui/JMeterFileFilter.java Sat Apr  8 09:26:24 2006
@@ -1,4 +1,3 @@
-// $Header$
 /*
  * Copyright 2001-2004 The Apache Software Foundation.
  *
@@ -25,24 +24,40 @@
  * A file filter which allows files to be filtered based on a list of allowed
  * extensions.
  * 
- * @author unknown
- * @version $Revision$
+ * Optionally returns directories.
+ * 
  */
 public class JMeterFileFilter extends javax.swing.filechooser.FileFilter implements java.io.FileFilter {
 	/** The list of extensions allowed by this filter. */
-	private String[] exts;
+	private final String[] exts;
+    
+    private final boolean allowDirs; // Should we allow directories?
 
 	/**
 	 * Create a new JMeter file filter which allows the specified extensions. If
 	 * the array of extensions contains no elements, any file will be allowed.
-	 * 
+     * 
+	 * This constructor will also return all directories
+     *  
 	 * @param extensions
 	 *            non-null array of allowed file extensions
 	 */
 	public JMeterFileFilter(String[] extensions) {
-		exts = extensions;
+        this(extensions,true);
 	}
 
+    /**
+     * Create a new JMeter file filter which allows the specified extensions. If
+     * the array of extensions contains no elements, any file will be allowed.
+     * 
+     * @param extensions non-null array of allowed file extensions
+     * @param allow should directories be returned ?
+     */
+    public JMeterFileFilter(String[] extensions, boolean allow) {
+        exts = extensions;
+        allowDirs = allow;
+    }
+
 	/**
 	 * Determine if the specified file is allowed by this filter. The file will
 	 * be allowed if it is a directory, or if the end of the filename matches
@@ -55,7 +70,7 @@
 	 * @return true if the file should be allowed, false otherwise
 	 */
 	public boolean accept(File f) {
-		return f.isDirectory() || accept(f.getName().toLowerCase());
+		return (allowDirs && f.isDirectory()) || accept(f.getName().toLowerCase());
 	}
 
 	/**



---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org