commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scolebou...@apache.org
Subject svn commit: r424745 - in /jakarta/commons/proper/io/trunk: ./ src/java/org/apache/commons/io/filefilter/ src/test/org/apache/commons/io/filefilter/
Date Sun, 23 Jul 2006 14:18:56 GMT
Author: scolebourne
Date: Sun Jul 23 07:18:55 2006
New Revision: 424745

URL: http://svn.apache.org/viewvc?rev=424745&view=rev
Log:
TrueFileFilter/FalseFileFilter/DirectoryFileFilter new constants
  - New singleton instance constants (TRUE/FALSE/DIRECTORY)
  - The new constants are more JDK 1.5 friendly with regards to static imports
    (whereas if everything uses INSTANCE, then they just clash)
  - The old INSTANCE constants are still present and have not been deprecated

Modified:
    jakarta/commons/proper/io/trunk/RELEASE-NOTES.txt
    jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/DirectoryFileFilter.java
    jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/FalseFileFilter.java
    jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/FileFilterUtils.java
    jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/TrueFileFilter.java
    jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/filefilter/FileFilterTestCase.java

Modified: jakarta/commons/proper/io/trunk/RELEASE-NOTES.txt
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/io/trunk/RELEASE-NOTES.txt?rev=424745&r1=424744&r2=424745&view=diff
==============================================================================
--- jakarta/commons/proper/io/trunk/RELEASE-NOTES.txt (original)
+++ jakarta/commons/proper/io/trunk/RELEASE-NOTES.txt Sun Jul 23 07:18:55 2006
@@ -75,6 +75,12 @@
   - New IOFileFilter implementation
   - Accepts files or directories that are empty
 
+- TrueFileFilter/FalseFileFilter/DirectoryFileFilter
+  - New singleton instance constants (TRUE/FALSE/DIRECTORY)
+  - The new constants are more JDK 1.5 friendly with regards to static imports
+    (whereas if everything uses INSTANCE, then they just clash)
+  - The old INSTANCE constants are still present and have not been deprecated
+
 
 Feedback
 --------

Modified: jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/DirectoryFileFilter.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/DirectoryFileFilter.java?rev=424745&r1=424744&r2=424745&view=diff
==============================================================================
--- jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/DirectoryFileFilter.java
(original)
+++ jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/DirectoryFileFilter.java
Sun Jul 23 07:18:55 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2004 The Apache Software Foundation.
+ * Copyright 2002-2004,2006 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -33,30 +33,40 @@
  *
  * @since Commons IO 1.0
  * @version $Revision$ $Date$
- * 
+ *
  * @author Henri Yandell
  * @author Stephen Colebourne
  * @author Peter Donald
  */
 public class DirectoryFileFilter extends AbstractFileFilter {
-    
-    /** Singleton instance of directory filter */
-    public static final IOFileFilter INSTANCE = new DirectoryFileFilter();
-    
+
+    /**
+     * Singleton instance of directory filter.
+     * @since Commons IO 1.3
+     */
+    public static final IOFileFilter DIRECTORY = new DirectoryFileFilter();
+    /**
+     * Singleton instance of directory filter.
+     * Please use the identical DirectoryFileFilter.DIRECTORY constant.
+     * The new name is more JDK 1.5 friendly as it doesn't clash with other
+     * values when using static imports.
+     */
+    public static final IOFileFilter INSTANCE = DIRECTORY;
+
     /**
      * Restrictive consructor.
      */
     protected DirectoryFileFilter() {
     }
-    
+
     /**
      * Checks to see if the file is a directory.
-     * 
+     *
      * @param file  the File to check
      * @return true if the file is a directory
      */
     public boolean accept(File file) {
         return file.isDirectory();
     }
-    
+
 }

Modified: jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/FalseFileFilter.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/FalseFileFilter.java?rev=424745&r1=424744&r2=424745&view=diff
==============================================================================
--- jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/FalseFileFilter.java
(original)
+++ jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/FalseFileFilter.java
Sun Jul 23 07:18:55 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2004 The Apache Software Foundation.
+ * Copyright 2002-2004,2006 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,37 +19,47 @@
 
 /**
  * A file filter that always returns false.
- * 
+ *
  * @since Commons IO 1.0
  * @version $Revision$ $Date$
- * 
+ *
  * @author Henri Yandell
  * @author Stephen Colebourne
  */
 public class FalseFileFilter implements IOFileFilter {
-    
-    /** Singleton instance of false filter */
-    public static final IOFileFilter INSTANCE = new FalseFileFilter();
-    
+
+    /**
+     * Singleton instance of false filter.
+     * @since Commons IO 1.3
+     */
+    public static final IOFileFilter FALSE = new FalseFileFilter();
+    /**
+     * Singleton instance of false filter.
+     * Please use the identical FalseFileFilter.FALSE constant.
+     * The new name is more JDK 1.5 friendly as it doesn't clash with other
+     * values when using static imports.
+     */
+    public static final IOFileFilter INSTANCE = FALSE;
+
     /**
      * Restrictive consructor.
      */
     protected FalseFileFilter() {
     }
-    
+
     /**
      * Returns false.
-     * 
+     *
      * @param file  the file to check
      * @return false
      */
     public boolean accept(File file) {
         return false;
     }
-    
+
     /**
      * Returns false.
-     * 
+     *
      * @param dir  the directory to check
      * @param name  the filename
      * @return false
@@ -57,5 +67,5 @@
     public boolean accept(File dir, String name) {
         return false;
     }
-    
+
 }

Modified: jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/FileFilterUtils.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/FileFilterUtils.java?rev=424745&r1=424744&r2=424745&view=diff
==============================================================================
--- jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/FileFilterUtils.java
(original)
+++ jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/FileFilterUtils.java
Sun Jul 23 07:18:55 2006
@@ -79,7 +79,7 @@
      * @return file filter that accepts only directories and not files
      */
     public static IOFileFilter directoryFileFilter() {
-        return DirectoryFileFilter.INSTANCE;
+        return DirectoryFileFilter.DIRECTORY;
     }
 
     /**
@@ -131,7 +131,7 @@
      * @return a true filter
      */
     public static IOFileFilter trueFileFilter() {
-        return TrueFileFilter.INSTANCE;
+        return TrueFileFilter.TRUE;
     }
 
     /**
@@ -140,7 +140,7 @@
      * @return a false filter
      */
     public static IOFileFilter falseFileFilter() {
-        return FalseFileFilter.INSTANCE;
+        return FalseFileFilter.FALSE;
     }
     
     //-----------------------------------------------------------------------

Modified: jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/TrueFileFilter.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/TrueFileFilter.java?rev=424745&r1=424744&r2=424745&view=diff
==============================================================================
--- jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/TrueFileFilter.java
(original)
+++ jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/TrueFileFilter.java
Sun Jul 23 07:18:55 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2004 The Apache Software Foundation.
+ * Copyright 2002-2004,2006 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,37 +19,47 @@
 
 /**
  * A file filter that always returns true.
- * 
+ *
  * @since Commons IO 1.0
  * @version $Revision$ $Date$
- * 
+ *
  * @author Henri Yandell
  * @author Stephen Colebourne
  */
 public class TrueFileFilter implements IOFileFilter {
-    
-    /** Singleton instance of true filter */
-    public static final IOFileFilter INSTANCE = new TrueFileFilter();
-    
+
+    /**
+     * Singleton instance of true filter.
+     * @since Commons IO 1.3
+     */
+    public static final IOFileFilter TRUE = new TrueFileFilter();
+    /**
+     * Singleton instance of true filter.
+     * Please use the identical TrueFileFilter.TRUE constant.
+     * The new name is more JDK 1.5 friendly as it doesn't clash with other
+     * values when using static imports.
+     */
+    public static final IOFileFilter INSTANCE = TRUE;
+
     /**
      * Restrictive consructor.
      */
     protected TrueFileFilter() {
     }
-    
+
     /**
      * Returns true.
-     * 
+     *
      * @param file  the file to check
      * @return true
      */
     public boolean accept(File file) {
         return true;
     }
-    
+
     /**
      * Returns true.
-     * 
+     *
      * @param dir  the directory to check
      * @param name  the filename
      * @return true
@@ -57,5 +67,5 @@
     public boolean accept(File dir, String name) {
         return true;
     }
-    
+
 }

Modified: jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/filefilter/FileFilterTestCase.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/filefilter/FileFilterTestCase.java?rev=424745&r1=424744&r2=424745&view=diff
==============================================================================
--- jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/filefilter/FileFilterTestCase.java
(original)
+++ jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/filefilter/FileFilterTestCase.java
Sun Jul 23 07:18:55 2006
@@ -136,6 +136,8 @@
         assertFiltering(filter, new File("imaginary/"), false);
 
         assertFiltering(filter, new File("STATUS.html"), false);
+        
+        assertSame(DirectoryFileFilter.DIRECTORY, DirectoryFileFilter.INSTANCE);
     }
 
     public void testFiles() throws Exception {
@@ -282,6 +284,7 @@
         assertFiltering(filter, new File("foo.test"), true);
         assertFiltering(filter, new File("foo"), true);
         assertFiltering(filter, null, true);
+        assertSame(TrueFileFilter.TRUE, TrueFileFilter.INSTANCE);
     }
 
     public void testFalse() throws Exception {
@@ -289,6 +292,7 @@
         assertFiltering(filter, new File("foo.test"), false);
         assertFiltering(filter, new File("foo"), false);
         assertFiltering(filter, null, false);
+        assertSame(FalseFileFilter.FALSE, FalseFileFilter.INSTANCE);
     }
 
     public void testNot() throws Exception {



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


Mime
View raw message