scolebourne 2004/10/25 15:53:27 Modified: io/src/java/org/apache/commons/io/filefilter ConditionalFileFilter.java WildcardFilter.java AndFileFilter.java OrFileFilter.java Log: Fix formatting to four spaces Revision Changes Path 1.2 +34 -34 jakarta-commons/io/src/java/org/apache/commons/io/filefilter/ConditionalFileFilter.java Index: ConditionalFileFilter.java =================================================================== RCS file: /home/cvs/jakarta-commons/io/src/java/org/apache/commons/io/filefilter/ConditionalFileFilter.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ConditionalFileFilter.java 24 Oct 2004 21:58:44 -0000 1.1 +++ ConditionalFileFilter.java 25 Oct 2004 22:53:26 -0000 1.2 @@ -23,40 +23,40 @@ * @since Commons IO 1.0 * @version $Revision$ $Date$ * - * @author Steven Caswell + * @author Steven Caswell */ -public interface ConditionalFileFilter -{ - /** - * Adds the specified file filter to the list of file filters at the end of - * the list. - * - * @param ioFileFilter the filter to be added - */ - public void addFileFilter(IOFileFilter ioFileFilter); +public interface ConditionalFileFilter { - /** - * Returns this conditional file filter's list of file filters. - * - * @return the file filter list - */ - public List getFileFilters(); - - /** - * Removes the specified file filter. - * - * @param ioFileFilter filter to be removed - * @return <code>true</code> if the filter was found in the list, - * <code>false</code> otherwise - */ - public boolean removeFileFilter(IOFileFilter ioFileFilter); + /** + * Adds the specified file filter to the list of file filters at the end of + * the list. + * + * @param ioFileFilter the filter to be added + */ + public void addFileFilter(IOFileFilter ioFileFilter); + + /** + * Returns this conditional file filter's list of file filters. + * + * @return the file filter list + */ + public List getFileFilters(); + + /** + * Removes the specified file filter. + * + * @param ioFileFilter filter to be removed + * @return <code>true</code> if the filter was found in the list, + * <code>false</code> otherwise + */ + public boolean removeFileFilter(IOFileFilter ioFileFilter); + + /** + * Sets the list of file filters, replacing any previously configured + * file filters on this filter. + * + * @param fileFilters the list of filters + */ + public void setFileFilters(List fileFilters); - /** - * Sets the list of file filters, replacing any previously configured - * file filters on this filter. - * - * @param fileFilters the list of filters - */ - public void setFileFilters(List fileFilters); - } 1.2 +84 -88 jakarta-commons/io/src/java/org/apache/commons/io/filefilter/WildcardFilter.java Index: WildcardFilter.java =================================================================== RCS file: /home/cvs/jakarta-commons/io/src/java/org/apache/commons/io/filefilter/WildcardFilter.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- WildcardFilter.java 22 Sep 2004 02:04:21 -0000 1.1 +++ WildcardFilter.java 25 Oct 2004 22:53:26 -0000 1.2 @@ -4,7 +4,6 @@ import java.util.List; import org.apache.commons.io.find.WildcardUtils; - /** * Filters files using supplied wildcard(s). * <p/> @@ -25,95 +24,92 @@ * @author Jason Anderson */ public class WildcardFilter extends AbstractFileFilter { - /** The wildcards that will be used to match filenames */ - private String[] wildcards = null; - - /** - * Construct a new wildcard filter for a single wildcard - * - * @param wildcard wildcard to match - * @throws IllegalArgumentException if the pattern is null - */ - public WildcardFilter(String wildcard) { - if (wildcard == null) { - throw new java.lang.IllegalArgumentException(); - } - wildcards = new String[] { wildcard }; - } + /** The wildcards that will be used to match filenames */ + private String[] wildcards = null; - - /** - * Construct a new wildcard filter for an array of wildcards - * - * @param wildcards wildcards to match - * @throws IllegalArgumentException if the pattern array is null - */ - public WildcardFilter(String[] wildcards) { - if (wildcards == null) { - throw new java.lang.IllegalArgumentException(); + /** + * Construct a new wildcard filter for a single wildcard + * + * @param wildcard wildcard to match + * @throws IllegalArgumentException if the pattern is null + */ + public WildcardFilter(String wildcard) { + if (wildcard == null) { + throw new java.lang.IllegalArgumentException(); + } + + wildcards = new String[] { wildcard }; + } + + /** + * Construct a new wildcard filter for an array of wildcards + * + * @param wildcards wildcards to match + * @throws IllegalArgumentException if the pattern array is null + */ + public WildcardFilter(String[] wildcards) { + if (wildcards == null) { + throw new java.lang.IllegalArgumentException(); + } + + this.wildcards = wildcards; + } + + /** + * Construct a new wildcard filter for a list of wildcards + * + * @param wildcards list of wildcards to match + * @throws IllegalArgumentException if the pattern list is null + * @throws ClassCastException if the list does not contain Strings + */ + public WildcardFilter(List wildcards) { + if (wildcards == null) { + throw new java.lang.IllegalArgumentException(); + } + + this.wildcards = (String[]) wildcards.toArray(new String[wildcards.size()]); + } + + /** + * Checks to see if the filename matches one of the wildcards. + * + * @param dir the file directory + * @param name the filename + * @return true if the filename matches one of the wildcards + */ + public boolean accept(File dir, String name) { + if (dir != null && new File(dir, name).isDirectory()) { + return false; + } + + for (int i = 0; i < wildcards.length; i++) { + if (WildcardUtils.match(name, wildcards[i])) { + return true; + } + } + + return false; + } + + /** + * Checks to see if the filename matches one of the wildcards. + * + * @param file the file to check + * @return true if the filename matches one of the wildcards + */ + public boolean accept(File file) { + if (file.isDirectory()) { + return false; + } + + for (int i = 0; i < wildcards.length; i++) { + if (WildcardUtils.match(file.getName(), wildcards[i])) { + return true; + } + } + + return false; } - - this.wildcards = wildcards; - } - - - /** - * Construct a new wildcard filter for a list of wildcards - * - * @param wildcards list of wildcards to match - * @throws IllegalArgumentException if the pattern list is null - * @throws ClassCastException if the list does not contain Strings - */ - public WildcardFilter(List wildcards) { - if (wildcards == null) { - throw new java.lang.IllegalArgumentException(); - } - - this.wildcards = (String[]) wildcards.toArray(new String[wildcards.size()]); - } - - - /** - * Checks to see if the filename matches one of the wildcards. - * - * @param dir the file directory - * @param name the filename - * @return true if the filename matches one of the wildcards - */ - public boolean accept(File dir, String name) { - if (dir != null && new File(dir, name).isDirectory()) { - return false; - } - - for (int i = 0; i < wildcards.length; i++) { - if (WildcardUtils.match(name, wildcards[i])) { - return true; - } - } - - return false; - } - - - /** - * Checks to see if the filename matches one of the wildcards. - * - * @param file the file to check - * @return true if the filename matches one of the wildcards - */ - public boolean accept(File file) { - if (file.isDirectory()) { - return false; - } - - for (int i = 0; i < wildcards.length; i++) { - if (WildcardUtils.match(file.getName(), wildcards[i])) { - return true; - } - } - - return false; - } } 1.10 +95 -95 jakarta-commons/io/src/java/org/apache/commons/io/filefilter/AndFileFilter.java Index: AndFileFilter.java =================================================================== RCS file: /home/cvs/jakarta-commons/io/src/java/org/apache/commons/io/filefilter/AndFileFilter.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- AndFileFilter.java 24 Oct 2004 21:58:44 -0000 1.9 +++ AndFileFilter.java 25 Oct 2004 22:53:26 -0000 1.10 @@ -31,104 +31,104 @@ * @since Commons IO 1.0 * @version $Revision$ $Date$ * - * @author Steven Caswell + * @author Steven Caswell */ public class AndFileFilter -extends AbstractFileFilter -implements IOFileFilter, ConditionalFileFilter { + extends AbstractFileFilter + implements IOFileFilter, ConditionalFileFilter { - private List fileFilters; + /** The list of file filters. */ + private List fileFilters; - /** - * Constructs a new instance of <code>AndFileFilter</code>. - */ - public AndFileFilter() { - this.fileFilters = new ArrayList(); - } - - /** - * Constructs a new instance of <code>AndFileFilter</code> - * with the specified list of filters. - */ - public AndFileFilter(final List fileFilters) { - this.fileFilters = new ArrayList(fileFilters); - } - - /** - * Constructs a new file filter that ANDs the result of two other filters. - * - * @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) { - throw new IllegalArgumentException("The filters must not be null"); - } - this.fileFilters = new ArrayList(); - addFileFilter(filter1); - addFileFilter(filter2); - } - - /** - * @{inheritDoc} - */ - public void addFileFilter(final IOFileFilter ioFileFilter) { - this.fileFilters.add(ioFileFilter); - } - - /** - * @{inheritDoc} - */ - public List getFileFilters() { - return Collections.unmodifiableList(this.fileFilters); - } - - /** - * @{inheritDoc} - */ - public boolean removeFileFilter(final IOFileFilter ioFileFilter) { - return this.fileFilters.remove(ioFileFilter); - } - - /** - * [EMAIL PROTECTED] - */ - public void setFileFilters(final List fileFilters) { - this.fileFilters = new ArrayList(fileFilters); - } - - /** - * @{inheritDoc} - */ - public boolean accept(final File file) { - if(this.fileFilters.size() == 0) { - return false; - } - for(Iterator iter = this.fileFilters.iterator(); iter.hasNext();) { - IOFileFilter fileFilter = (IOFileFilter) iter.next(); - if(!fileFilter.accept(file)) { - return false; - } - } - return true; - } - - /** - * @{inheritDoc} - */ - public boolean accept(final File file, final String name) - { - if(this.fileFilters.size() == 0) { - return false; - } - for(Iterator iter = this.fileFilters.iterator(); iter.hasNext();) { - IOFileFilter fileFilter = (IOFileFilter) iter.next(); - if(!fileFilter.accept(file, name)) { - return false; - } + /** + * Constructs a new instance of <code>AndFileFilter</code>. + */ + public AndFileFilter() { + this.fileFilters = new ArrayList(); + } + + /** + * Constructs a new instance of <code>AndFileFilter</code> + * with the specified list of filters. + */ + public AndFileFilter(final List fileFilters) { + this.fileFilters = new ArrayList(fileFilters); + } + + /** + * Constructs a new file filter that ANDs the result of two other filters. + * + * @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) { + throw new IllegalArgumentException("The filters must not be null"); + } + this.fileFilters = new ArrayList(); + addFileFilter(filter1); + addFileFilter(filter2); + } + + /** + * @{inheritDoc} + */ + public void addFileFilter(final IOFileFilter ioFileFilter) { + this.fileFilters.add(ioFileFilter); + } + + /** + * @{inheritDoc} + */ + public List getFileFilters() { + return Collections.unmodifiableList(this.fileFilters); + } + + /** + * @{inheritDoc} + */ + public boolean removeFileFilter(final IOFileFilter ioFileFilter) { + return this.fileFilters.remove(ioFileFilter); + } + + /** + * [EMAIL PROTECTED] + */ + public void setFileFilters(final List fileFilters) { + this.fileFilters = new ArrayList(fileFilters); + } + + /** + * @{inheritDoc} + */ + public boolean accept(final File file) { + if (this.fileFilters.size() == 0) { + return false; + } + for (Iterator iter = this.fileFilters.iterator(); iter.hasNext();) { + IOFileFilter fileFilter = (IOFileFilter) iter.next(); + if (!fileFilter.accept(file)) { + return false; + } + } + return true; + } + + /** + * @{inheritDoc} + */ + public boolean accept(final File file, final String name) { + if (this.fileFilters.size() == 0) { + return false; + } + for (Iterator iter = this.fileFilters.iterator(); iter.hasNext();) { + IOFileFilter fileFilter = (IOFileFilter) iter.next(); + if (!fileFilter.accept(file, name)) { + return false; + } + } + return true; } - return true; - } } 1.10 +92 -90 jakarta-commons/io/src/java/org/apache/commons/io/filefilter/OrFileFilter.java Index: OrFileFilter.java =================================================================== RCS file: /home/cvs/jakarta-commons/io/src/java/org/apache/commons/io/filefilter/OrFileFilter.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- OrFileFilter.java 24 Oct 2004 21:58:44 -0000 1.9 +++ OrFileFilter.java 25 Oct 2004 22:53:26 -0000 1.10 @@ -31,98 +31,100 @@ * @since Commons IO 1.0 * @version $Revision$ $Date$ * - * @author Steven Caswell + * @author Steven Caswell */ public class OrFileFilter - extends AbstractFileFilter - implements IOFileFilter, ConditionalFileFilter { + extends AbstractFileFilter + implements IOFileFilter, ConditionalFileFilter { - private List fileFilters; + /** The list of file filters. */ + private List fileFilters; - /** - * Constructs a new instance of <code>OrFileFilter</code>. - */ - public OrFileFilter() { - this.fileFilters = new ArrayList(); - } - - /** - * Constructs a new instance of <code>OrFileFilter</code> - * with the specified filters. - * - * @param fileFileter the file filters for this filter - */ - public OrFileFilter(final List fileFilters) { - this.fileFilters = new ArrayList(fileFilters); - } - - /** - * Constructs a new file filter that ORs the result of two other filters. - * - * @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) { - throw new IllegalArgumentException("The filters must not be null"); - } - this.fileFilters = new ArrayList(); - addFileFilter(filter1); - addFileFilter(filter2); - } - - /** - * [EMAIL PROTECTED] - */ - public void addFileFilter(final IOFileFilter ioFileFilter) { - this.fileFilters.add(ioFileFilter); - } - - /** - * [EMAIL PROTECTED] - */ - public List getFileFilters() { - return Collections.unmodifiableList(this.fileFilters); - } - - /** - * [EMAIL PROTECTED] - */ - public boolean removeFileFilter(IOFileFilter ioFileFilter) { - return this.fileFilters.remove(ioFileFilter); - } - - /** - * [EMAIL PROTECTED] - */ - public void setFileFilters(final List fileFilters) { - this.fileFilters = fileFilters; - } - - /** - * [EMAIL PROTECTED] - */ - public boolean accept(final File file) { - for(Iterator iter = this.fileFilters.iterator(); iter.hasNext();) { - IOFileFilter fileFilter = (IOFileFilter) iter.next(); - if(fileFilter.accept(file)) { - return true; - } - } - return false; - } - - /** - * [EMAIL PROTECTED] - */ - public boolean accept(final File file, final String name) { - for(Iterator iter = this.fileFilters.iterator(); iter.hasNext();) { - IOFileFilter fileFilter = (IOFileFilter) iter.next(); - if(fileFilter.accept(file, name)) { - return true; - } + /** + * Constructs a new instance of <code>OrFileFilter</code>. + */ + public OrFileFilter() { + this.fileFilters = new ArrayList(); } - return false; - } + + /** + * Constructs a new instance of <code>OrFileFilter</code> + * with the specified filters. + * + * @param fileFileter the file filters for this filter + */ + public OrFileFilter(final List fileFilters) { + this.fileFilters = new ArrayList(fileFilters); + } + + /** + * Constructs a new file filter that ORs the result of two other filters. + * + * @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) { + throw new IllegalArgumentException("The filters must not be null"); + } + this.fileFilters = new ArrayList(); + addFileFilter(filter1); + addFileFilter(filter2); + } + + /** + * [EMAIL PROTECTED] + */ + public void addFileFilter(final IOFileFilter ioFileFilter) { + this.fileFilters.add(ioFileFilter); + } + + /** + * [EMAIL PROTECTED] + */ + public List getFileFilters() { + return Collections.unmodifiableList(this.fileFilters); + } + + /** + * [EMAIL PROTECTED] + */ + public boolean removeFileFilter(IOFileFilter ioFileFilter) { + return this.fileFilters.remove(ioFileFilter); + } + + /** + * [EMAIL PROTECTED] + */ + public void setFileFilters(final List fileFilters) { + this.fileFilters = fileFilters; + } + + /** + * [EMAIL PROTECTED] + */ + public boolean accept(final File file) { + for (Iterator iter = this.fileFilters.iterator(); iter.hasNext();) { + IOFileFilter fileFilter = (IOFileFilter) iter.next(); + if (fileFilter.accept(file)) { + return true; + } + } + return false; + } + + /** + * [EMAIL PROTECTED] + */ + public boolean accept(final File file, final String name) { + for (Iterator iter = this.fileFilters.iterator(); iter.hasNext();) { + IOFileFilter fileFilter = (IOFileFilter) iter.next(); + if (fileFilter.accept(file, name)) { + return true; + } + } + return false; + } + }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]