Skip to content

Commit 95cddf5

Browse files
author
Stephen Colebourne
committed
Javadoc
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/io/trunk@140389 13f79535-47bb-0310-9956-ffa450edef68
1 parent 002483f commit 95cddf5

8 files changed

Lines changed: 74 additions & 36 deletions

File tree

src/java/org/apache/commons/io/filefilter/AndFileFilter.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* ====================================================================
22
* The Apache Software License, Version 1.1
33
*
4-
* Copyright (c) 2003 The Apache Software Foundation. All rights
4+
* Copyright (c) 2002-2003 The Apache Software Foundation. All rights
55
* reserved.
66
*
77
* Redistribution and use in source and binary forms, with or without
@@ -59,7 +59,7 @@
5959
* This filter produces a logical AND of the two filters specified.
6060
*
6161
* @since Commons IO 1.0
62-
* @version $Revision: 1.4 $ $Date: 2003/07/27 17:11:38 $
62+
* @version $Revision: 1.5 $ $Date: 2003/09/20 19:52:38 $
6363
*
6464
* @author Stephen Colebourne
6565
*/
@@ -73,8 +73,9 @@ public class AndFileFilter extends AbstractFileFilter {
7373
/**
7474
* Constructs a new file filter that ANDs the result of two other filters.
7575
*
76-
* @param filter1 the first filter
77-
* @param filter2 the second filter
76+
* @param filter1 the first filter, must not be null
77+
* @param filter2 the second filter, must not be null
78+
* @throws IllegalArgumentException if either filter is null
7879
*/
7980
public AndFileFilter(IOFileFilter filter1, IOFileFilter filter2) {
8081
if (filter1 == null || filter2 == null) {

src/java/org/apache/commons/io/filefilter/FalseFileFilter.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* ====================================================================
22
* The Apache Software License, Version 1.1
33
*
4-
* Copyright (c) 2003 The Apache Software Foundation. All rights
4+
* Copyright (c) 2002-2003 The Apache Software Foundation. All rights
55
* reserved.
66
*
77
* Redistribution and use in source and binary forms, with or without
@@ -59,7 +59,7 @@
5959
* A file filter that always returns false.
6060
*
6161
* @since Commons IO 1.0
62-
* @version $Revision: 1.2 $ $Date: 2003/07/27 17:11:38 $
62+
* @version $Revision: 1.3 $ $Date: 2003/09/20 19:52:38 $
6363
*
6464
* @author Henri Yandell
6565
* @author Stephen Colebourne
@@ -76,7 +76,7 @@ protected FalseFileFilter() {
7676
}
7777

7878
/**
79-
* Return false.
79+
* Returns false.
8080
*
8181
* @param file the file to check
8282
* @return false
@@ -86,7 +86,7 @@ public boolean accept(File file) {
8686
}
8787

8888
/**
89-
* Return false.
89+
* Returns false.
9090
*
9191
* @param dir the directory to check
9292
* @param name the filename

src/java/org/apache/commons/io/filefilter/FileFilterUtils.java

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,14 @@
5353
*/
5454
package org.apache.commons.io.filefilter;
5555

56+
import java.io.FileFilter;
57+
import java.io.FilenameFilter;
58+
5659
/**
5760
* Useful utilities for working with file filters.
5861
*
5962
* @since Commons IO 1.0
60-
* @version $Revision: 1.3 $ $Date: 2003/07/27 17:11:38 $
63+
* @version $Revision: 1.4 $ $Date: 2003/09/20 19:52:38 $
6164
*
6265
* @author Henri Yandell
6366
* @author Stephen Colebourne
@@ -67,7 +70,7 @@ public class FileFilterUtils {
6770
/**
6871
* FileFilterUtils is not normally instantiated.
6972
*/
70-
private FileFilterUtils() {
73+
public FileFilterUtils() {
7174
}
7275

7376
//-----------------------------------------------------------------------
@@ -100,6 +103,7 @@ public static IOFileFilter directoryFileFilter() {
100103
return DirectoryFileFilter.INSTANCE;
101104
}
102105

106+
//-----------------------------------------------------------------------
103107
/**
104108
* Returns a filter that ANDs the two specified filters.
105109
*
@@ -132,6 +136,7 @@ public static IOFileFilter notFileFilter(IOFileFilter filter) {
132136
return new NotFileFilter(filter);
133137
}
134138

139+
//-----------------------------------------------------------------------
135140
/**
136141
* Returns a filter that always returns true.
137142
*
@@ -150,4 +155,27 @@ public static IOFileFilter falseFileFilter() {
150155
return FalseFileFilter.INSTANCE;
151156
}
152157

158+
//-----------------------------------------------------------------------
159+
/**
160+
* Returns an <code>IOFileFilter</code> that wraps the
161+
* <code>FileFilter</code> instance.
162+
*
163+
* @param filter the filter to be wrapped
164+
* @return a new filter that implements IOFileFilter
165+
*/
166+
public static IOFileFilter asFileFilter(FileFilter filter) {
167+
return new DelegateFileFilter(filter);
168+
}
169+
170+
/**
171+
* Returns an <code>IOFileFilter</code> that wraps the
172+
* <code>FilenameFilter</code> instance.
173+
*
174+
* @param filter the filter to be wrapped
175+
* @return a new filter that implements IOFileFilter
176+
*/
177+
public static IOFileFilter asFileFilter(FilenameFilter filter) {
178+
return new DelegateFileFilter(filter);
179+
}
180+
153181
}

src/java/org/apache/commons/io/filefilter/NotFileFilter.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* ====================================================================
22
* The Apache Software License, Version 1.1
33
*
4-
* Copyright (c) 2003 The Apache Software Foundation. All rights
4+
* Copyright (c) 2002-2003 The Apache Software Foundation. All rights
55
* reserved.
66
*
77
* Redistribution and use in source and binary forms, with or without
@@ -59,7 +59,7 @@
5959
* This filter produces a logical NOT of the filters specified.
6060
*
6161
* @since Commons IO 1.0
62-
* @version $Revision: 1.2 $ $Date: 2003/07/27 17:11:38 $
62+
* @version $Revision: 1.3 $ $Date: 2003/09/20 19:52:38 $
6363
*
6464
* @author Stephen Colebourne
6565
*/
@@ -71,7 +71,8 @@ public class NotFileFilter extends AbstractFileFilter {
7171
/**
7272
* Constructs a new file filter that NOTs the result of another filters.
7373
*
74-
* @param filter the filter
74+
* @param filter the filter, must not be null
75+
* @throws IllegalArgumentException if the filter is null
7576
*/
7677
public NotFileFilter(IOFileFilter filter) {
7778
if (filter == null) {

src/java/org/apache/commons/io/filefilter/OrFileFilter.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* ====================================================================
22
* The Apache Software License, Version 1.1
33
*
4-
* Copyright (c) 2003 The Apache Software Foundation. All rights
4+
* Copyright (c) 2002-2003 The Apache Software Foundation. All rights
55
* reserved.
66
*
77
* Redistribution and use in source and binary forms, with or without
@@ -59,7 +59,7 @@
5959
* This filter produces a logical OR of the two filters specified.
6060
*
6161
* @since Commons IO 1.0
62-
* @version $Revision: 1.4 $ $Date: 2003/07/27 17:11:38 $
62+
* @version $Revision: 1.5 $ $Date: 2003/09/20 19:52:38 $
6363
*
6464
* @author Stephen Colebourne
6565
*/
@@ -73,8 +73,9 @@ public class OrFileFilter extends AbstractFileFilter {
7373
/**
7474
* Constructs a new file filter that ORs the result of two other filters.
7575
*
76-
* @param filter1 the first filter
77-
* @param filter2 the second filter
76+
* @param filter1 the first filter, must not be null
77+
* @param filter2 the second filter, must not be null
78+
* @throws IllegalArgumentException if either filter is null
7879
*/
7980
public OrFileFilter(IOFileFilter filter1, IOFileFilter filter2) {
8081
if (filter1 == null || filter2 == null) {

src/java/org/apache/commons/io/filefilter/PrefixFileFilter.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,21 +57,21 @@
5757
import java.util.List;
5858

5959
/**
60-
* This filters filenames for a certain prefix.
60+
* Filters filenames for a certain prefix.
6161
* <p>
6262
* For example, to print all files and directories in the
63-
* current directory whose name starts with <code>foo</code>:
63+
* current directory whose name starts with <code>Test</code>:
6464
*
6565
* <pre>
6666
* File dir = new File(".");
67-
* String[] files = dir.list( new PrefixFileFilter("foo"));
67+
* String[] files = dir.list( new PrefixFileFilter("Test") );
6868
* for ( int i = 0; i &lt; files.length; i++ ) {
6969
* System.out.println(files[i]);
7070
* }
7171
* </pre>
7272
*
7373
* @since Commons IO 1.0
74-
* @version $Revision: 1.3 $ $Date: 2003/07/27 17:11:38 $
74+
* @version $Revision: 1.4 $ $Date: 2003/09/20 19:52:38 $
7575
*
7676
* @author Henri Yandell
7777
* @author Stephen Colebourne
@@ -81,13 +81,14 @@
8181
*/
8282
public class PrefixFileFilter extends AbstractFileFilter {
8383

84-
/** The filename prefix to search for */
84+
/** The filename prefixes to search for */
8585
private String[] prefixes;
8686

8787
/**
8888
* Constructs a new Prefix file filter for a single prefix.
8989
*
90-
* @param prefix the prefix to allow, null means none
90+
* @param prefix the prefix to allow, must not be null
91+
* @throws IllegalArgumentException if the prefix is null
9192
*/
9293
public PrefixFileFilter(final String prefix) {
9394
if (prefixes == null) {
@@ -97,12 +98,13 @@ public PrefixFileFilter(final String prefix) {
9798
}
9899

99100
/**
100-
* Constructs a new Prefix file filter for an array of prefixes.
101+
* Constructs a new Prefix file filter for any of an array of prefixes.
101102
* <p>
102103
* The array is not cloned, so could be changed after constructing the
103104
* instance. This would be inadvisable however.
104105
*
105-
* @param prefixes the prefixes to allow, null means none
106+
* @param prefixes the prefixes to allow, must not be null
107+
* @throws IllegalArgumentException if the prefix array is null
106108
*/
107109
public PrefixFileFilter(final String[] prefixes) {
108110
if (prefixes == null) {
@@ -114,7 +116,9 @@ public PrefixFileFilter(final String[] prefixes) {
114116
/**
115117
* Constructs a new Prefix file filter for a list of prefixes.
116118
*
117-
* @param prefixes the prefixes to allow, null means none
119+
* @param prefixes the prefixes to allow, must not be null
120+
* @throws IllegalArgumentException if the prefix list is null
121+
* @throws ClassCastException if the list does not contain Strings
118122
*/
119123
public PrefixFileFilter(final List prefixes) {
120124
if (prefixes == null) {
@@ -124,7 +128,7 @@ public PrefixFileFilter(final List prefixes) {
124128
}
125129

126130
/**
127-
* Checks to see if the filename ends with the prefix.
131+
* Checks to see if the filename starts with the prefix.
128132
*
129133
* @param file the File to check
130134
* @return true if the filename starts with one of our prefixes

src/java/org/apache/commons/io/filefilter/SuffixFileFilter.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,23 +57,22 @@
5757
import java.util.List;
5858

5959
/**
60-
* This filters files based on the suffix (what the filename
61-
* ends with). This is used in retrieving all the files of a
62-
* particular type.
60+
* Filters files based on the suffix (what the filename ends with).
61+
* This is used in retrieving all the files of a particular type.
6362
* <p>
6463
* For example, to retrieve and print all <code>*.java</code> files
6564
* in the current directory:
6665
*
6766
* <pre>
6867
* File dir = new File(".");
69-
* String[] files = dir.list( new SuffixFileFilter( new String[]{".java"} ) );
68+
* String[] files = dir.list( new SuffixFileFilter(".java") );
7069
* for (int i = 0; i &lt; files.length; i++) {
7170
* System.out.println(files[i]);
7271
* }
7372
* </pre>
7473
*
7574
* @since Commons IO 1.0
76-
* @version $Revision: 1.2 $ $Date: 2003/07/27 17:11:38 $
75+
* @version $Revision: 1.3 $ $Date: 2003/09/20 19:52:38 $
7776
*
7877
* @author Henri Yandell
7978
* @author Stephen Colebourne
@@ -90,6 +89,7 @@ public class SuffixFileFilter extends AbstractFileFilter {
9089
* Constructs a new Suffix file filter for a single extension.
9190
*
9291
* @param suffix the suffix to allow, must not be null
92+
* @throws IllegalArgumentException if the suffix is null
9393
*/
9494
public SuffixFileFilter(final String suffix) {
9595
if (suffix == null) {
@@ -105,6 +105,7 @@ public SuffixFileFilter(final String suffix) {
105105
* instance. This would be inadvisable however.
106106
*
107107
* @param suffixes the suffixes to allow, must not be null
108+
* @throws IllegalArgumentException if the suffix array is null
108109
*/
109110
public SuffixFileFilter(final String[] suffixes) {
110111
if (suffixes == null) {
@@ -117,6 +118,8 @@ public SuffixFileFilter(final String[] suffixes) {
117118
* Constructs a new Suffix file filter for a list of suffixes.
118119
*
119120
* @param suffixes the suffixes to allow, must not be null
121+
* @throws IllegalArgumentException if the suffix list is null
122+
* @throws ClassCastException if the list does not contain Strings
120123
*/
121124
public SuffixFileFilter(final List suffixes) {
122125
if (suffixes == null) {

src/java/org/apache/commons/io/filefilter/TrueFileFilter.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* ====================================================================
22
* The Apache Software License, Version 1.1
33
*
4-
* Copyright (c) 2003 The Apache Software Foundation. All rights
4+
* Copyright (c) 2002-2003 The Apache Software Foundation. All rights
55
* reserved.
66
*
77
* Redistribution and use in source and binary forms, with or without
@@ -59,7 +59,7 @@
5959
* A file filter that always returns true.
6060
*
6161
* @since Commons IO 1.0
62-
* @version $Revision: 1.2 $ $Date: 2003/07/27 17:11:38 $
62+
* @version $Revision: 1.3 $ $Date: 2003/09/20 19:52:38 $
6363
*
6464
* @author Henri Yandell
6565
* @author Stephen Colebourne
@@ -76,7 +76,7 @@ protected TrueFileFilter() {
7676
}
7777

7878
/**
79-
* Return true.
79+
* Returns true.
8080
*
8181
* @param file the file to check
8282
* @return true
@@ -86,7 +86,7 @@ public boolean accept(File file) {
8686
}
8787

8888
/**
89-
* Return true.
89+
* Returns true.
9090
*
9191
* @param dir the directory to check
9292
* @param name the filename

0 commit comments

Comments
 (0)