Author: jeremias
Date: Fri Jun 24 05:35:32 2005
New Revision: 201606

URL: http://svn.apache.org/viewcvs?rev=201606&view=rev
Log:
Added a FileFilterUtils.makeSVNAware() taking the makeCVSAware() as a template.

Modified:
    
jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/FileFilterUtils.java
    
jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/filefilter/FileFilterTestCase.java

Modified: 
jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/FileFilterUtils.java
URL: 
http://svn.apache.org/viewcvs/jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/FileFilterUtils.java?rev=201606&r1=201605&r2=201606&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
 Fri Jun 24 05:35:32 2005
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2004 The Apache Software Foundation.
+ * Copyright 2002-2005 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.
@@ -159,6 +159,9 @@
     /* Constructed on demand and then cached */
     private static IOFileFilter cvsFilter;
 
+    /* Constructed on demand and then cached */
+    private static IOFileFilter svnFilter;
+
     /**
      * Returns an IOFileFilter that ignores CVS directories. You may optionally
      * pass in an existing IOFileFilter in which case it is extended to exclude
@@ -177,6 +180,27 @@
             return cvsFilter;
         } else {
             return andFileFilter(filter, cvsFilter);
+        }
+    }
+
+    /**
+     * Returns an IOFileFilter that ignores SVN directories. You may optionally
+     * pass in an existing IOFileFilter in which case it is extended to exclude
+     * SVN directories.
+     * @param filter IOFileFilter to wrap, null if a new IOFileFilter
+     * should be created
+     * @return the requested (combined) filter
+     * @since 1.1
+     */
+    public static IOFileFilter makeSVNAware(IOFileFilter filter) {
+        if (svnFilter == null) {
+            svnFilter = notFileFilter(
+                andFileFilter(directoryFileFilter(), nameFileFilter(".svn")));
+        }
+        if (filter == null) {
+            return svnFilter;
+        } else {
+            return andFileFilter(filter, svnFilter);
         }
     }
 

Modified: 
jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/filefilter/FileFilterTestCase.java
URL: 
http://svn.apache.org/viewcvs/jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/filefilter/FileFilterTestCase.java?rev=201606&r1=201605&r2=201606&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
 Fri Jun 24 05:35:32 2005
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2004 The Apache Software Foundation.
+ * Copyright 2002-2005 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.
@@ -252,6 +252,33 @@
         assertFiltering(filter2, file, false);
 
         file = new File(getTestDirectory(), "CVS");
+        createFile(file, 0);
+        assertFiltering(filter1, file, true);
+        assertFiltering(filter2, file, false);
+    }
+         
+    public void testMakeSVNAware() throws Exception {
+        IOFileFilter filter1 = FileFilterUtils.makeSVNAware(null);
+        IOFileFilter filter2 = FileFilterUtils.makeSVNAware(FileFilterUtils
+            .nameFileFilter("test-file1.txt"));
+
+        File file = new File(getTestDirectory(), ".svn");
+        file.mkdirs();
+        assertFiltering(filter1, file, false);
+        assertFiltering(filter2, file, false);
+        FileUtils.deleteDirectory(file);
+
+        file = new File(getTestDirectory(), "test-file1.txt");
+        createFile(file, 0);
+        assertFiltering(filter1, file, true);
+        assertFiltering(filter2, file, true);
+
+        file = new File(getTestDirectory(), "test-file2.log");
+        createFile(file, 0);
+        assertFiltering(filter1, file, true);
+        assertFiltering(filter2, file, false);
+
+        file = new File(getTestDirectory(), ".svn");
         createFile(file, 0);
         assertFiltering(filter1, file, true);
         assertFiltering(filter2, file, false);



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to