commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Niall Pemberton (JIRA)" <j...@apache.org>
Subject [jira] Issue Comment Edited: (IO-119) Convenience "Builder" for creating complex FileFilter conditions
Date Sat, 09 Feb 2008 01:06:08 GMT

    [ https://issues.apache.org/jira/browse/IO-119?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12567257#action_12567257
] 

niallp edited comment on IO-119 at 2/8/08 5:05 PM:
------------------------------------------------------------

Isn't that what we already have in FileFilterUtils?
http://commons.apache.org/io/api-release/org/apache/commons/io/filefilter/FileFilterUtils.html

New version attached - I don't think theres an intuitive way to do and/or together - so I've
simplified by removing that, add singleton instances for AND/OR, added regex and provided
better size / lastmodified methods.

 So for example, to create a file filter for the following conditions
  - Either, directories which are not hidden and not named ".svn"
  - or, files which have a suffix of ".java"

{code}
    FileFilterBuilder directoryBuilder = FileFilterBuilder.AND
                           .isDirectory()
                           .isNotHidden()
                           .not().name(".svn");
 
     FileFilterBuilder fileBuilder = FileFilterBuilder.AND
                          .isFile()
                          .suffix(".java");

    FileFilter filter = FileFilterBuilder.OR
                          .add(directoryBuilder)
                          .add(fileBuilder)
                          .toFileFilter();
{code}

      was (Author: niallp):
    Isn't that what we already have in FileFilterUtils?
http://commons.apache.org/io/api-release/org/apache/commons/io/filefilter/FileFilterUtils.html

New version attached - I don't think theres an intuitive way to do and/or together - so I've
simplified by removing that, add singleton instances for AND/OR, added regex and provided
better size / lastmodified methods.

 So for example, to create a file filter for the following conditions
  - Either, directories which are not hidden and not named ".svn"
  - or, files which have a suffix of ".java"

    FileFilterBuilder directoryBuilder = FileFilterBuilder.AND
                           .isDirectory()
                           .isHidden(false)
                           .not().name(".svn");
 
     FileFilterBuilder fileBuilder = FileFilterBuilder.AND
                          .isFile()
                          .suffix(".java");

    FileFilter filter = FileFilterBuilder.OR
                          .add(directoryBuilder)
                          .add(fileBuilder)
                          .toFileFilter();

  
> Convenience "Builder" for creating complex FileFilter conditions
> ----------------------------------------------------------------
>
>                 Key: IO-119
>                 URL: https://issues.apache.org/jira/browse/IO-119
>             Project: Commons IO
>          Issue Type: Improvement
>          Components: Filters
>    Affects Versions: 1.3.1
>            Reporter: Niall Pemberton
>            Assignee: Niall Pemberton
>            Priority: Minor
>             Fix For: 2.x
>
>         Attachments: FileFilterBuilder.java, FileFilterBuilderTestCase.java
>
>
> I'd like to add a new convenience "builder" class (FileFilterBuilder) to make it easier
to create complex FileFilter using Commons IO's IOFileFilter implementations.
> Heres an example of how it can be used to create a IOFileFilter for the following conditions:
>  - Either, directories which are not hidden and not named ".svn"
>  - or, files which have a suffix of ".java"
>     IOFileFilter filter = FileFilterBuilder.orBuilder()
>         .and().isDirectory().isHidden(false).not().name(".svn").end()
>         .and().isFile().suffix(".java").end()
>         .getFileFilter();

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message