You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by sc...@apache.org on 2003/09/20 21:52:39 UTC
cvs commit: jakarta-commons-sandbox/io/src/java/org/apache/commons/io/filefilter FileFilterUtils.java TrueFileFilter.java SuffixFileFilter.java FalseFileFilter.java PrefixFileFilter.java AndFileFilter.java NotFileFilter.java OrFileFilter.java
scolebourne 2003/09/20 12:52:39
Modified: io/src/java/org/apache/commons/io/filefilter
FileFilterUtils.java TrueFileFilter.java
SuffixFileFilter.java FalseFileFilter.java
PrefixFileFilter.java AndFileFilter.java
NotFileFilter.java OrFileFilter.java
Log:
Javadoc
Revision Changes Path
1.4 +30 -2 jakarta-commons-sandbox/io/src/java/org/apache/commons/io/filefilter/FileFilterUtils.java
Index: FileFilterUtils.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/io/src/java/org/apache/commons/io/filefilter/FileFilterUtils.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- FileFilterUtils.java 27 Jul 2003 17:11:38 -0000 1.3
+++ FileFilterUtils.java 20 Sep 2003 19:52:38 -0000 1.4
@@ -53,6 +53,9 @@
*/
package org.apache.commons.io.filefilter;
+import java.io.FileFilter;
+import java.io.FilenameFilter;
+
/**
* Useful utilities for working with file filters.
*
@@ -67,7 +70,7 @@
/**
* FileFilterUtils is not normally instantiated.
*/
- private FileFilterUtils() {
+ public FileFilterUtils() {
}
//-----------------------------------------------------------------------
@@ -100,6 +103,7 @@
return DirectoryFileFilter.INSTANCE;
}
+ //-----------------------------------------------------------------------
/**
* Returns a filter that ANDs the two specified filters.
*
@@ -132,6 +136,7 @@
return new NotFileFilter(filter);
}
+ //-----------------------------------------------------------------------
/**
* Returns a filter that always returns true.
*
@@ -150,4 +155,27 @@
return FalseFileFilter.INSTANCE;
}
+ //-----------------------------------------------------------------------
+ /**
+ * Returns an <code>IOFileFilter</code> that wraps the
+ * <code>FileFilter</code> instance.
+ *
+ * @param filter the filter to be wrapped
+ * @return a new filter that implements IOFileFilter
+ */
+ public static IOFileFilter asFileFilter(FileFilter filter) {
+ return new DelegateFileFilter(filter);
+ }
+
+ /**
+ * Returns an <code>IOFileFilter</code> that wraps the
+ * <code>FilenameFilter</code> instance.
+ *
+ * @param filter the filter to be wrapped
+ * @return a new filter that implements IOFileFilter
+ */
+ public static IOFileFilter asFileFilter(FilenameFilter filter) {
+ return new DelegateFileFilter(filter);
+ }
+
}
1.3 +4 -4 jakarta-commons-sandbox/io/src/java/org/apache/commons/io/filefilter/TrueFileFilter.java
Index: TrueFileFilter.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/io/src/java/org/apache/commons/io/filefilter/TrueFileFilter.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TrueFileFilter.java 27 Jul 2003 17:11:38 -0000 1.2
+++ TrueFileFilter.java 20 Sep 2003 19:52:38 -0000 1.3
@@ -1,7 +1,7 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2003 The Apache Software Foundation. All rights
+ * Copyright (c) 2002-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -76,7 +76,7 @@
}
/**
- * Return true.
+ * Returns true.
*
* @param file the file to check
* @return true
@@ -86,7 +86,7 @@
}
/**
- * Return true.
+ * Returns true.
*
* @param dir the directory to check
* @param name the filename
1.3 +8 -5 jakarta-commons-sandbox/io/src/java/org/apache/commons/io/filefilter/SuffixFileFilter.java
Index: SuffixFileFilter.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/io/src/java/org/apache/commons/io/filefilter/SuffixFileFilter.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SuffixFileFilter.java 27 Jul 2003 17:11:38 -0000 1.2
+++ SuffixFileFilter.java 20 Sep 2003 19:52:38 -0000 1.3
@@ -57,16 +57,15 @@
import java.util.List;
/**
- * This filters files based on the suffix (what the filename
- * ends with). This is used in retrieving all the files of a
- * particular type.
+ * Filters files based on the suffix (what the filename ends with).
+ * This is used in retrieving all the files of a particular type.
* <p>
* For example, to retrieve and print all <code>*.java</code> files
* in the current directory:
*
* <pre>
* File dir = new File(".");
- * String[] files = dir.list( new SuffixFileFilter( new String[]{".java"} ) );
+ * String[] files = dir.list( new SuffixFileFilter(".java") );
* for (int i = 0; i < files.length; i++) {
* System.out.println(files[i]);
* }
@@ -90,6 +89,7 @@
* Constructs a new Suffix file filter for a single extension.
*
* @param suffix the suffix to allow, must not be null
+ * @throws IllegalArgumentException if the suffix is null
*/
public SuffixFileFilter(final String suffix) {
if (suffix == null) {
@@ -105,6 +105,7 @@
* instance. This would be inadvisable however.
*
* @param suffixes the suffixes to allow, must not be null
+ * @throws IllegalArgumentException if the suffix array is null
*/
public SuffixFileFilter(final String[] suffixes) {
if (suffixes == null) {
@@ -117,6 +118,8 @@
* Constructs a new Suffix file filter for a list of suffixes.
*
* @param suffixes the suffixes to allow, must not be null
+ * @throws IllegalArgumentException if the suffix list is null
+ * @throws ClassCastException if the list does not contain Strings
*/
public SuffixFileFilter(final List suffixes) {
if (suffixes == null) {
1.3 +4 -4 jakarta-commons-sandbox/io/src/java/org/apache/commons/io/filefilter/FalseFileFilter.java
Index: FalseFileFilter.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/io/src/java/org/apache/commons/io/filefilter/FalseFileFilter.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- FalseFileFilter.java 27 Jul 2003 17:11:38 -0000 1.2
+++ FalseFileFilter.java 20 Sep 2003 19:52:38 -0000 1.3
@@ -1,7 +1,7 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2003 The Apache Software Foundation. All rights
+ * Copyright (c) 2002-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -76,7 +76,7 @@
}
/**
- * Return false.
+ * Returns false.
*
* @param file the file to check
* @return false
@@ -86,7 +86,7 @@
}
/**
- * Return false.
+ * Returns false.
*
* @param dir the directory to check
* @param name the filename
1.4 +14 -10 jakarta-commons-sandbox/io/src/java/org/apache/commons/io/filefilter/PrefixFileFilter.java
Index: PrefixFileFilter.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/io/src/java/org/apache/commons/io/filefilter/PrefixFileFilter.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- PrefixFileFilter.java 27 Jul 2003 17:11:38 -0000 1.3
+++ PrefixFileFilter.java 20 Sep 2003 19:52:38 -0000 1.4
@@ -57,14 +57,14 @@
import java.util.List;
/**
- * This filters filenames for a certain prefix.
+ * Filters filenames for a certain prefix.
* <p>
* For example, to print all files and directories in the
- * current directory whose name starts with <code>foo</code>:
+ * current directory whose name starts with <code>Test</code>:
*
* <pre>
* File dir = new File(".");
- * String[] files = dir.list( new PrefixFileFilter("foo"));
+ * String[] files = dir.list( new PrefixFileFilter("Test") );
* for ( int i = 0; i < files.length; i++ ) {
* System.out.println(files[i]);
* }
@@ -81,13 +81,14 @@
*/
public class PrefixFileFilter extends AbstractFileFilter {
- /** The filename prefix to search for */
+ /** The filename prefixes to search for */
private String[] prefixes;
/**
* Constructs a new Prefix file filter for a single prefix.
*
- * @param prefix the prefix to allow, null means none
+ * @param prefix the prefix to allow, must not be null
+ * @throws IllegalArgumentException if the prefix is null
*/
public PrefixFileFilter(final String prefix) {
if (prefixes == null) {
@@ -97,12 +98,13 @@
}
/**
- * Constructs a new Prefix file filter for an array of prefixes.
+ * Constructs a new Prefix file filter for any of an array of prefixes.
* <p>
* The array is not cloned, so could be changed after constructing the
* instance. This would be inadvisable however.
*
- * @param prefixes the prefixes to allow, null means none
+ * @param prefixes the prefixes to allow, must not be null
+ * @throws IllegalArgumentException if the prefix array is null
*/
public PrefixFileFilter(final String[] prefixes) {
if (prefixes == null) {
@@ -114,7 +116,9 @@
/**
* Constructs a new Prefix file filter for a list of prefixes.
*
- * @param prefixes the prefixes to allow, null means none
+ * @param prefixes the prefixes to allow, must not be null
+ * @throws IllegalArgumentException if the prefix list is null
+ * @throws ClassCastException if the list does not contain Strings
*/
public PrefixFileFilter(final List prefixes) {
if (prefixes == null) {
@@ -124,7 +128,7 @@
}
/**
- * Checks to see if the filename ends with the prefix.
+ * Checks to see if the filename starts with the prefix.
*
* @param file the File to check
* @return true if the filename starts with one of our prefixes
1.5 +5 -4 jakarta-commons-sandbox/io/src/java/org/apache/commons/io/filefilter/AndFileFilter.java
Index: AndFileFilter.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/io/src/java/org/apache/commons/io/filefilter/AndFileFilter.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- AndFileFilter.java 27 Jul 2003 17:11:38 -0000 1.4
+++ AndFileFilter.java 20 Sep 2003 19:52:38 -0000 1.5
@@ -1,7 +1,7 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2003 The Apache Software Foundation. All rights
+ * Copyright (c) 2002-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -73,8 +73,9 @@
/**
* Constructs a new file filter that ANDs the result of two other filters.
*
- * @param filter1 the first filter
- * @param filter2 the second filter
+ * @param filter1 the first filter, must not be null
+ * @param filter2 the second filter, must not be null
+ * @throws IllegalArgumentException if either filter is null
*/
public AndFileFilter(IOFileFilter filter1, IOFileFilter filter2) {
if (filter1 == null || filter2 == null) {
1.3 +4 -3 jakarta-commons-sandbox/io/src/java/org/apache/commons/io/filefilter/NotFileFilter.java
Index: NotFileFilter.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/io/src/java/org/apache/commons/io/filefilter/NotFileFilter.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- NotFileFilter.java 27 Jul 2003 17:11:38 -0000 1.2
+++ NotFileFilter.java 20 Sep 2003 19:52:38 -0000 1.3
@@ -1,7 +1,7 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2003 The Apache Software Foundation. All rights
+ * Copyright (c) 2002-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -71,7 +71,8 @@
/**
* Constructs a new file filter that NOTs the result of another filters.
*
- * @param filter the filter
+ * @param filter the filter, must not be null
+ * @throws IllegalArgumentException if the filter is null
*/
public NotFileFilter(IOFileFilter filter) {
if (filter == null) {
1.5 +5 -4 jakarta-commons-sandbox/io/src/java/org/apache/commons/io/filefilter/OrFileFilter.java
Index: OrFileFilter.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/io/src/java/org/apache/commons/io/filefilter/OrFileFilter.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- OrFileFilter.java 27 Jul 2003 17:11:38 -0000 1.4
+++ OrFileFilter.java 20 Sep 2003 19:52:38 -0000 1.5
@@ -1,7 +1,7 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2003 The Apache Software Foundation. All rights
+ * Copyright (c) 2002-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -73,8 +73,9 @@
/**
* Constructs a new file filter that ORs the result of two other filters.
*
- * @param filter1 the first filter
- * @param filter2 the second filter
+ * @param filter1 the first filter, must not be null
+ * @param filter2 the second filter, must not be null
+ * @throws IllegalArgumentException if either filter is null
*/
public OrFileFilter(IOFileFilter filter1, IOFileFilter filter2) {
if (filter1 == null || filter2 == null) {