commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nia...@apache.org
Subject svn commit: r539231 - /jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/
Date Fri, 18 May 2007 03:10:34 GMT
Author: niallp
Date: Thu May 17 20:10:33 2007
New Revision: 539231

URL: http://svn.apache.org/viewvc?view=rev&rev=539231
Log:
IO-120 Improve file filter toString() methods

Modified:
    jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/AbstractFileFilter.java
    jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/AgeFileFilter.java
    jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/AndFileFilter.java
    jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/DelegateFileFilter.java
    jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/NameFileFilter.java
    jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/NotFileFilter.java
    jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/OrFileFilter.java
    jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/PrefixFileFilter.java
    jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/SizeFileFilter.java
    jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/SuffixFileFilter.java
    jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/WildcardFileFilter.java

Modified: jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/AbstractFileFilter.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/AbstractFileFilter.java?view=diff&rev=539231&r1=539230&r2=539231
==============================================================================
--- jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/AbstractFileFilter.java
(original)
+++ jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/AbstractFileFilter.java
Thu May 17 20:10:33 2007
@@ -53,4 +53,15 @@
         return accept(new File(dir, name));
     }
 
+    /**
+     * Provide a String representaion of this file filter.
+     *
+     * @return a String representaion
+     */
+    public String toString() {
+        String name = getClass().getName();
+        int period = name.lastIndexOf('.');
+        return (period > 0 ? name.substring(period + 1) : name);
+    }
+
 }

Modified: jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/AgeFileFilter.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/AgeFileFilter.java?view=diff&rev=539231&r1=539230&r2=539231
==============================================================================
--- jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/AgeFileFilter.java
(original)
+++ jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/AgeFileFilter.java
Thu May 17 20:10:33 2007
@@ -137,4 +137,13 @@
         return acceptOlder ? !newer : newer;
     }
 
+    /**
+     * Provide a String representaion of this file filter.
+     *
+     * @return a String representaion
+     */
+    public String toString() {
+        String condition = acceptOlder ? "<=" : ">";
+        return super.toString() + "(" + condition + cutoff + ")";
+    }
 }

Modified: jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/AndFileFilter.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/AndFileFilter.java?view=diff&rev=539231&r1=539230&r2=539231
==============================================================================
--- jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/AndFileFilter.java
(original)
+++ jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/AndFileFilter.java
Thu May 17 20:10:33 2007
@@ -141,4 +141,26 @@
         return true;
     }
 
+    /**
+     * Provide a String representaion of this file filter.
+     *
+     * @return a String representaion
+     */
+    public String toString() {
+        StringBuffer buffer = new StringBuffer();
+        buffer.append(super.toString());
+        buffer.append("(");
+        if (fileFilters != null) {
+            for (int i = 0; i < fileFilters.size(); i++) {
+                if (i > 0) {
+                    buffer.append(",");
+                }
+                Object filter = fileFilters.get(i);
+                buffer.append(filter == null ? "null" : filter.toString());
+            }
+        }
+        buffer.append(")");
+        return buffer.toString();
+    }
+
 }

Modified: jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/DelegateFileFilter.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/DelegateFileFilter.java?view=diff&rev=539231&r1=539230&r2=539231
==============================================================================
--- jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/DelegateFileFilter.java
(original)
+++ jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/DelegateFileFilter.java
Thu May 17 20:10:33 2007
@@ -87,5 +87,15 @@
             return super.accept(dir, name);
         }
     }
+
+    /**
+     * Provide a String representaion of this file filter.
+     *
+     * @return a String representaion
+     */
+    public String toString() {
+        String delegate = (fileFilter != null ? fileFilter.toString() : filenameFilter.toString());

+        return super.toString() + "(" + delegate.toString() + ")";
+    }
     
 }

Modified: jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/NameFileFilter.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/NameFileFilter.java?view=diff&rev=539231&r1=539230&r2=539231
==============================================================================
--- jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/NameFileFilter.java
(original)
+++ jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/NameFileFilter.java
Thu May 17 20:10:33 2007
@@ -166,4 +166,25 @@
         return false;
     }
 
+    /**
+     * Provide a String representaion of this file filter.
+     *
+     * @return a String representaion
+     */
+    public String toString() {
+        StringBuffer buffer = new StringBuffer();
+        buffer.append(super.toString());
+        buffer.append("(");
+        if (names != null) {
+            for (int i = 0; i < names.length; i++) {
+                if (i > 0) {
+                    buffer.append(",");
+                }
+                buffer.append(names[i]);
+            }
+        }
+        buffer.append(")");
+        return buffer.toString();
+    }
+
 }

Modified: jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/NotFileFilter.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/NotFileFilter.java?view=diff&rev=539231&r1=539230&r2=539231
==============================================================================
--- jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/NotFileFilter.java
(original)
+++ jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/NotFileFilter.java
Thu May 17 20:10:33 2007
@@ -64,5 +64,14 @@
     public boolean accept(File file, String name) {
         return ! filter.accept(file, name);
     }
+
+    /**
+     * Provide a String representaion of this file filter.
+     *
+     * @return a String representaion
+     */
+    public String toString() {
+        return super.toString() + "(" + filter.toString()  + ")";
+    }
     
 }

Modified: jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/OrFileFilter.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/OrFileFilter.java?view=diff&rev=539231&r1=539230&r2=539231
==============================================================================
--- jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/OrFileFilter.java
(original)
+++ jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/OrFileFilter.java
Thu May 17 20:10:33 2007
@@ -135,4 +135,26 @@
         return false;
     }
 
+    /**
+     * Provide a String representaion of this file filter.
+     *
+     * @return a String representaion
+     */
+    public String toString() {
+        StringBuffer buffer = new StringBuffer();
+        buffer.append(super.toString());
+        buffer.append("(");
+        if (fileFilters != null) {
+            for (int i = 0; i < fileFilters.size(); i++) {
+                if (i > 0) {
+                    buffer.append(",");
+                }
+                Object filter = fileFilters.get(i);
+                buffer.append(filter == null ? "null" : filter.toString());
+            }
+        }
+        buffer.append(")");
+        return buffer.toString();
+    }
+
 }

Modified: jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/PrefixFileFilter.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/PrefixFileFilter.java?view=diff&rev=539231&r1=539230&r2=539231
==============================================================================
--- jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/PrefixFileFilter.java
(original)
+++ jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/PrefixFileFilter.java
Thu May 17 20:10:33 2007
@@ -120,5 +120,26 @@
         }
         return false;
     }
+
+    /**
+     * Provide a String representaion of this file filter.
+     *
+     * @return a String representaion
+     */
+    public String toString() {
+        StringBuffer buffer = new StringBuffer();
+        buffer.append(super.toString());
+        buffer.append("(");
+        if (prefixes != null) {
+            for (int i = 0; i < prefixes.length; i++) {
+                if (i > 0) {
+                    buffer.append(",");
+                }
+                buffer.append(prefixes[i]);
+            }
+        }
+        buffer.append(")");
+        return buffer.toString();
+    }
     
 }

Modified: jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/SizeFileFilter.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/SizeFileFilter.java?view=diff&rev=539231&r1=539230&r2=539231
==============================================================================
--- jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/SizeFileFilter.java
(original)
+++ jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/SizeFileFilter.java
Thu May 17 20:10:33 2007
@@ -89,4 +89,14 @@
         return acceptLarger ? !smaller : smaller;
     }
 
+    /**
+     * Provide a String representaion of this file filter.
+     *
+     * @return a String representaion
+     */
+    public String toString() {
+        String condition = acceptLarger ? ">=" : "<";
+        return super.toString() + "(" + condition + size + ")";
+    }
+
 }

Modified: jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/SuffixFileFilter.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/SuffixFileFilter.java?view=diff&rev=539231&r1=539230&r2=539231
==============================================================================
--- jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/SuffixFileFilter.java
(original)
+++ jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/SuffixFileFilter.java
Thu May 17 20:10:33 2007
@@ -121,5 +121,26 @@
         }
         return false;
     }
+
+    /**
+     * Provide a String representaion of this file filter.
+     *
+     * @return a String representaion
+     */
+    public String toString() {
+        StringBuffer buffer = new StringBuffer();
+        buffer.append(super.toString());
+        buffer.append("(");
+        if (suffixes != null) {
+            for (int i = 0; i < suffixes.length; i++) {
+                if (i > 0) {
+                    buffer.append(",");
+                }
+                buffer.append(suffixes[i]);
+            }
+        }
+        buffer.append(")");
+        return buffer.toString();
+    }
     
 }

Modified: jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/WildcardFileFilter.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/WildcardFileFilter.java?view=diff&rev=539231&r1=539230&r2=539231
==============================================================================
--- jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/WildcardFileFilter.java
(original)
+++ jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/filefilter/WildcardFileFilter.java
Thu May 17 20:10:33 2007
@@ -45,7 +45,7 @@
  * </pre>
  *
  * @author Jason Anderson
- * @version $Revision: 155419 $ $Date: 2006-06-26 00:19:58 +0100 (Mon, 26 Jun 2006) $
+ * @version $Revision: 155419 $ $Date$
  * @since Commons IO 1.3
  */
 public class WildcardFileFilter extends AbstractFileFilter {
@@ -169,6 +169,27 @@
             }
         }
         return false;
+    }
+
+    /**
+     * Provide a String representaion of this file filter.
+     *
+     * @return a String representaion
+     */
+    public String toString() {
+        StringBuffer buffer = new StringBuffer();
+        buffer.append(super.toString());
+        buffer.append("(");
+        if (wildcards != null) {
+            for (int i = 0; i < wildcards.length; i++) {
+                if (i > 0) {
+                    buffer.append(",");
+                }
+                buffer.append(wildcards[i]);
+            }
+        }
+        buffer.append(")");
+        return buffer.toString();
     }
 
 }



---------------------------------------------------------------------
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