You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Niall Pemberton (JIRA)" <ji...@apache.org> on 2006/07/24 18:24:13 UTC

[jira] Created: (IO-89) Inconsistency in SizeFileFilter and AgeFileFilter implementations

Inconsistency in SizeFileFilter and AgeFileFilter implementations
-----------------------------------------------------------------

                 Key: IO-89
                 URL: http://issues.apache.org/jira/browse/IO-89
             Project: Commons IO
          Issue Type: Bug
          Components: Filters
    Affects Versions: 1.2
            Reporter: Niall Pemberton
            Priority: Minor
             Fix For: 1.3


Theres an inconsistency (bug?) in the implementation of SizeFileFilter and AgeFileFilter.

In SizeFileFilter, using an "acceptLarger" parameter of true actually accepts files with a size equal to and larger, whereas
specifying an "acceptLarger" parameter of false only accepts smaller files.

The same is true for AgeFileFilter, using an "acceptOlder" parameter of true actually accepts files either the same age or older, whereas
specifying an "acceptOlder" parameter of false only accepts newer files.


A big benefit of resolving these inconsistencies would mean that creating filters for any condition (i.e. <, >, <=, >= or =) becomes
alot easier. For example if the AgeFileFilter did only do either newer or older, then creating a filters for "the same age or older"
or "the same age or younger" could be done in the following way:

    IOFileFilter equalOlder   = new NotFileFilter(new AgeFileFilter(cutoff, false));
    IOFileFilter equalYounger = new NotFileFilter(new AgeFileFilter(cutoff, true));


For SizeFileFilter I propose changing the logic to the following:

    if (acceptLarger) {
        return file.length() >= size;
    } else {
        return file.length() <= size;
    }

(This would mean that "new SizeFileFilter(cutoff)" would operate the same way)

I have added isOlderFile() methods to FileUtils and propose that AgeFileFilter is changed to the following:

    if (acceptOlder) {
        return FileUtils.isFileOlder(file, cutoff);
    } else {
        return FileUtils.isFileNewer(file, cutoff);
    }


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


[jira] Commented: (IO-89) Inconsistency in SizeFileFilter and AgeFileFilter implementations

Posted by "Stephen Colebourne (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/IO-89?page=comments#action_12423209 ] 
            
Stephen Colebourne commented on IO-89:
--------------------------------------

I'm behind on reviewing commits, but the key thing is backwards compatability. The internal implementation (number of classes/flexibility) is less important.

> Inconsistency in SizeFileFilter and AgeFileFilter implementations
> -----------------------------------------------------------------
>
>                 Key: IO-89
>                 URL: http://issues.apache.org/jira/browse/IO-89
>             Project: Commons IO
>          Issue Type: Bug
>          Components: Filters
>    Affects Versions: 1.2
>            Reporter: Niall Pemberton
>            Priority: Minor
>             Fix For: 1.3
>
>
> Theres an inconsistency (bug?) in the implementation of SizeFileFilter and AgeFileFilter.
> In SizeFileFilter, using an "acceptLarger" parameter of true actually accepts files with a size equal to and larger, whereas
> specifying an "acceptLarger" parameter of false only accepts smaller files.
> The same is true for AgeFileFilter, using an "acceptOlder" parameter of true actually accepts files either the same age or older, whereas
> specifying an "acceptOlder" parameter of false only accepts newer files.
> A big benefit of resolving these inconsistencies would mean that creating filters for any condition (i.e. <, >, <=, >= or =) becomes
> alot easier. For example if the AgeFileFilter did only do either newer or older, then creating a filters for "the same age or older"
> or "the same age or younger" could be done in the following way:
>     IOFileFilter equalOlder   = new NotFileFilter(new AgeFileFilter(cutoff, false));
>     IOFileFilter equalYounger = new NotFileFilter(new AgeFileFilter(cutoff, true));
> For SizeFileFilter I propose changing the logic to the following:
>     if (acceptLarger) {
>         return file.length() >= size;
>     } else {
>         return file.length() <= size;
>     }
> (This would mean that "new SizeFileFilter(cutoff)" would operate the same way)
> I have added isOlderFile() methods to FileUtils and propose that AgeFileFilter is changed to the following:
>     if (acceptOlder) {
>         return FileUtils.isFileOlder(file, cutoff);
>     } else {
>         return FileUtils.isFileNewer(file, cutoff);
>     }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


[jira] Commented: (IO-89) Inconsistency in SizeFileFilter and AgeFileFilter implementations

Posted by "Niall Pemberton (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/IO-89?page=comments#action_12440743 ] 
            
Niall Pemberton commented on IO-89:
-----------------------------------

OK forget the last thing I said - back to my original suggestion - I understand your compatibility issues but I think this is a bug for the following reasons and so should be fixed:

1) It doesn't do what it says it does in the javadocs
2) The larger/smaller and older/newer are inconsistent.

> Inconsistency in SizeFileFilter and AgeFileFilter implementations
> -----------------------------------------------------------------
>
>                 Key: IO-89
>                 URL: http://issues.apache.org/jira/browse/IO-89
>             Project: Commons IO
>          Issue Type: Bug
>          Components: Filters
>    Affects Versions: 1.2
>            Reporter: Niall Pemberton
>            Priority: Minor
>             Fix For: 1.3
>
>
> Theres an inconsistency (bug?) in the implementation of SizeFileFilter and AgeFileFilter.
> In SizeFileFilter, using an "acceptLarger" parameter of true actually accepts files with a size equal to and larger, whereas
> specifying an "acceptLarger" parameter of false only accepts smaller files.
> The same is true for AgeFileFilter, using an "acceptOlder" parameter of true actually accepts files either the same age or older, whereas
> specifying an "acceptOlder" parameter of false only accepts newer files.
> A big benefit of resolving these inconsistencies would mean that creating filters for any condition (i.e. <, >, <=, >= or =) becomes
> alot easier. For example if the AgeFileFilter did only do either newer or older, then creating a filters for "the same age or older"
> or "the same age or younger" could be done in the following way:
>     IOFileFilter equalOlder   = new NotFileFilter(new AgeFileFilter(cutoff, false));
>     IOFileFilter equalYounger = new NotFileFilter(new AgeFileFilter(cutoff, true));
> For SizeFileFilter I propose changing the logic to the following:
>     if (acceptLarger) {
>         return file.length() >= size;
>     } else {
>         return file.length() <= size;
>     }
> (This would mean that "new SizeFileFilter(cutoff)" would operate the same way)
> I have added isOlderFile() methods to FileUtils and propose that AgeFileFilter is changed to the following:
>     if (acceptOlder) {
>         return FileUtils.isFileOlder(file, cutoff);
>     } else {
>         return FileUtils.isFileNewer(file, cutoff);
>     }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


[jira] Updated: (IO-89) Inconsistency in SizeFileFilter and AgeFileFilter implementations

Posted by "Niall Pemberton (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/IO-89?page=all ]

Niall Pemberton updated IO-89:
------------------------------

    Fix Version/s: 1.4
                       (was: 1.3)

I've corrected the AgeFileFilter and SizeFileFilter javadocs.

Another solution would be to add two new equivalent (but without the inconsistency) filters - LengthFileFilter (uses file.length() ) & LastModifiedFileFilter (uses  file.lastModified()) and deprecate SizeFileFilter & AgeFileFilter.

Whatever the solution I'm not sure when/if I'll get round to this, so I've punted the fix version to 1.4 for now.

> Inconsistency in SizeFileFilter and AgeFileFilter implementations
> -----------------------------------------------------------------
>
>                 Key: IO-89
>                 URL: http://issues.apache.org/jira/browse/IO-89
>             Project: Commons IO
>          Issue Type: Bug
>          Components: Filters
>    Affects Versions: 1.2
>            Reporter: Niall Pemberton
>            Priority: Minor
>             Fix For: 1.4
>
>
> Theres an inconsistency (bug?) in the implementation of SizeFileFilter and AgeFileFilter.
> In SizeFileFilter, using an "acceptLarger" parameter of true actually accepts files with a size equal to and larger, whereas
> specifying an "acceptLarger" parameter of false only accepts smaller files.
> The same is true for AgeFileFilter, using an "acceptOlder" parameter of true actually accepts files either the same age or older, whereas
> specifying an "acceptOlder" parameter of false only accepts newer files.
> A big benefit of resolving these inconsistencies would mean that creating filters for any condition (i.e. <, >, <=, >= or =) becomes
> alot easier. For example if the AgeFileFilter did only do either newer or older, then creating a filters for "the same age or older"
> or "the same age or younger" could be done in the following way:
>     IOFileFilter equalOlder   = new NotFileFilter(new AgeFileFilter(cutoff, false));
>     IOFileFilter equalYounger = new NotFileFilter(new AgeFileFilter(cutoff, true));
> For SizeFileFilter I propose changing the logic to the following:
>     if (acceptLarger) {
>         return file.length() >= size;
>     } else {
>         return file.length() <= size;
>     }
> (This would mean that "new SizeFileFilter(cutoff)" would operate the same way)
> I have added isOlderFile() methods to FileUtils and propose that AgeFileFilter is changed to the following:
>     if (acceptOlder) {
>         return FileUtils.isFileOlder(file, cutoff);
>     } else {
>         return FileUtils.isFileNewer(file, cutoff);
>     }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


[jira] Commented: (IO-89) Inconsistency in SizeFileFilter and AgeFileFilter implementations

Posted by "Niall Pemberton (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/IO-89?page=comments#action_12441503 ] 
            
Niall Pemberton commented on IO-89:
-----------------------------------

My final proposal is actually what I originally proposed, but you pointed out earlier "the key thing is backward" compatibilty. IMO we should fix it because I think the inconsistency is a bug. From my point of view theres three options here:

1) Fix It - modify as per my original proposal
2) Punt the issue to 1.4 until theres consensus (so it doesn't hold up 1.3)
3) Close it as WONT FIX

> Inconsistency in SizeFileFilter and AgeFileFilter implementations
> -----------------------------------------------------------------
>
>                 Key: IO-89
>                 URL: http://issues.apache.org/jira/browse/IO-89
>             Project: Commons IO
>          Issue Type: Bug
>          Components: Filters
>    Affects Versions: 1.2
>            Reporter: Niall Pemberton
>            Priority: Minor
>             Fix For: 1.3
>
>
> Theres an inconsistency (bug?) in the implementation of SizeFileFilter and AgeFileFilter.
> In SizeFileFilter, using an "acceptLarger" parameter of true actually accepts files with a size equal to and larger, whereas
> specifying an "acceptLarger" parameter of false only accepts smaller files.
> The same is true for AgeFileFilter, using an "acceptOlder" parameter of true actually accepts files either the same age or older, whereas
> specifying an "acceptOlder" parameter of false only accepts newer files.
> A big benefit of resolving these inconsistencies would mean that creating filters for any condition (i.e. <, >, <=, >= or =) becomes
> alot easier. For example if the AgeFileFilter did only do either newer or older, then creating a filters for "the same age or older"
> or "the same age or younger" could be done in the following way:
>     IOFileFilter equalOlder   = new NotFileFilter(new AgeFileFilter(cutoff, false));
>     IOFileFilter equalYounger = new NotFileFilter(new AgeFileFilter(cutoff, true));
> For SizeFileFilter I propose changing the logic to the following:
>     if (acceptLarger) {
>         return file.length() >= size;
>     } else {
>         return file.length() <= size;
>     }
> (This would mean that "new SizeFileFilter(cutoff)" would operate the same way)
> I have added isOlderFile() methods to FileUtils and propose that AgeFileFilter is changed to the following:
>     if (acceptOlder) {
>         return FileUtils.isFileOlder(file, cutoff);
>     } else {
>         return FileUtils.isFileNewer(file, cutoff);
>     }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


[jira] Commented: (IO-89) Inconsistency in SizeFileFilter and AgeFileFilter implementations

Posted by "Niall Pemberton (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/IO-89?page=comments#action_12423156 ] 
            
Niall Pemberton commented on IO-89:
-----------------------------------

I tried it out that way first (I have the changes ready to commit) with SizeFileFilter - but in my mind having the limits included seems slightly more suitable - for example up to and including 2MB or 2MB and over seems more desirable as the default behaviour. It also makes the "size range" filter simpler (uses 3 filters, rather than 4).

Having said that, if others agree with you  then I'm not strongly fixed to this pov. I expected the issue to be more over backwards compatibility - which would be a shame since the main issue is consistency of behaviour and what it will allow if they are consistent.

> Inconsistency in SizeFileFilter and AgeFileFilter implementations
> -----------------------------------------------------------------
>
>                 Key: IO-89
>                 URL: http://issues.apache.org/jira/browse/IO-89
>             Project: Commons IO
>          Issue Type: Bug
>          Components: Filters
>    Affects Versions: 1.2
>            Reporter: Niall Pemberton
>            Priority: Minor
>             Fix For: 1.3
>
>
> Theres an inconsistency (bug?) in the implementation of SizeFileFilter and AgeFileFilter.
> In SizeFileFilter, using an "acceptLarger" parameter of true actually accepts files with a size equal to and larger, whereas
> specifying an "acceptLarger" parameter of false only accepts smaller files.
> The same is true for AgeFileFilter, using an "acceptOlder" parameter of true actually accepts files either the same age or older, whereas
> specifying an "acceptOlder" parameter of false only accepts newer files.
> A big benefit of resolving these inconsistencies would mean that creating filters for any condition (i.e. <, >, <=, >= or =) becomes
> alot easier. For example if the AgeFileFilter did only do either newer or older, then creating a filters for "the same age or older"
> or "the same age or younger" could be done in the following way:
>     IOFileFilter equalOlder   = new NotFileFilter(new AgeFileFilter(cutoff, false));
>     IOFileFilter equalYounger = new NotFileFilter(new AgeFileFilter(cutoff, true));
> For SizeFileFilter I propose changing the logic to the following:
>     if (acceptLarger) {
>         return file.length() >= size;
>     } else {
>         return file.length() <= size;
>     }
> (This would mean that "new SizeFileFilter(cutoff)" would operate the same way)
> I have added isOlderFile() methods to FileUtils and propose that AgeFileFilter is changed to the following:
>     if (acceptOlder) {
>         return FileUtils.isFileOlder(file, cutoff);
>     } else {
>         return FileUtils.isFileNewer(file, cutoff);
>     }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


[jira] Commented: (IO-89) Inconsistency in SizeFileFilter and AgeFileFilter implementations

Posted by "Stephen Colebourne (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/IO-89?page=comments#action_12441499 ] 
            
Stephen Colebourne commented on IO-89:
--------------------------------------

Where are we with this? Have you got a finalised proposal? Certainly bug squashing and javadoc fixes  are good.

> Inconsistency in SizeFileFilter and AgeFileFilter implementations
> -----------------------------------------------------------------
>
>                 Key: IO-89
>                 URL: http://issues.apache.org/jira/browse/IO-89
>             Project: Commons IO
>          Issue Type: Bug
>          Components: Filters
>    Affects Versions: 1.2
>            Reporter: Niall Pemberton
>            Priority: Minor
>             Fix For: 1.3
>
>
> Theres an inconsistency (bug?) in the implementation of SizeFileFilter and AgeFileFilter.
> In SizeFileFilter, using an "acceptLarger" parameter of true actually accepts files with a size equal to and larger, whereas
> specifying an "acceptLarger" parameter of false only accepts smaller files.
> The same is true for AgeFileFilter, using an "acceptOlder" parameter of true actually accepts files either the same age or older, whereas
> specifying an "acceptOlder" parameter of false only accepts newer files.
> A big benefit of resolving these inconsistencies would mean that creating filters for any condition (i.e. <, >, <=, >= or =) becomes
> alot easier. For example if the AgeFileFilter did only do either newer or older, then creating a filters for "the same age or older"
> or "the same age or younger" could be done in the following way:
>     IOFileFilter equalOlder   = new NotFileFilter(new AgeFileFilter(cutoff, false));
>     IOFileFilter equalYounger = new NotFileFilter(new AgeFileFilter(cutoff, true));
> For SizeFileFilter I propose changing the logic to the following:
>     if (acceptLarger) {
>         return file.length() >= size;
>     } else {
>         return file.length() <= size;
>     }
> (This would mean that "new SizeFileFilter(cutoff)" would operate the same way)
> I have added isOlderFile() methods to FileUtils and propose that AgeFileFilter is changed to the following:
>     if (acceptOlder) {
>         return FileUtils.isFileOlder(file, cutoff);
>     } else {
>         return FileUtils.isFileNewer(file, cutoff);
>     }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


[jira] Commented: (IO-89) Inconsistency in SizeFileFilter and AgeFileFilter implementations

Posted by "Niall Pemberton (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/IO-89?page=comments#action_12423215 ] 
            
Niall Pemberton commented on IO-89:
-----------------------------------

OK so this needs re-thinking. IMO it should be easy to use any of the five compare operators (i.e. <, <=, =, >=, >) with the size or age filters.

So maybe we should have a constructor which takes the size and operator - and deprecate the existing boolean parameter constructors:

   public SizeFileFilter(long size, boolean acceptLarger) {
       this(size, acceptLarger ? ">=" : "<");
   }

   public SizeFileFilter(long size, String operator) {
       this.size = size;
       this.operator = operator;
   }

   public boolean accept(File file) {
       if ("<".equals(operator)) {
           return file.length() < size;
       } else if ("<=".equals(operator)) {
           return file.length() <= size;
       } else if ("=".equals(operator)) {
           return file.length() == size;
       } else if (">=".equals(operator)) {
           return file.length() >= size;
       } else if (">".equals(operator)) {
           return file.length() > size;
       }
   }

When I get time I'll put together a patch for review

> Inconsistency in SizeFileFilter and AgeFileFilter implementations
> -----------------------------------------------------------------
>
>                 Key: IO-89
>                 URL: http://issues.apache.org/jira/browse/IO-89
>             Project: Commons IO
>          Issue Type: Bug
>          Components: Filters
>    Affects Versions: 1.2
>            Reporter: Niall Pemberton
>            Priority: Minor
>             Fix For: 1.3
>
>
> Theres an inconsistency (bug?) in the implementation of SizeFileFilter and AgeFileFilter.
> In SizeFileFilter, using an "acceptLarger" parameter of true actually accepts files with a size equal to and larger, whereas
> specifying an "acceptLarger" parameter of false only accepts smaller files.
> The same is true for AgeFileFilter, using an "acceptOlder" parameter of true actually accepts files either the same age or older, whereas
> specifying an "acceptOlder" parameter of false only accepts newer files.
> A big benefit of resolving these inconsistencies would mean that creating filters for any condition (i.e. <, >, <=, >= or =) becomes
> alot easier. For example if the AgeFileFilter did only do either newer or older, then creating a filters for "the same age or older"
> or "the same age or younger" could be done in the following way:
>     IOFileFilter equalOlder   = new NotFileFilter(new AgeFileFilter(cutoff, false));
>     IOFileFilter equalYounger = new NotFileFilter(new AgeFileFilter(cutoff, true));
> For SizeFileFilter I propose changing the logic to the following:
>     if (acceptLarger) {
>         return file.length() >= size;
>     } else {
>         return file.length() <= size;
>     }
> (This would mean that "new SizeFileFilter(cutoff)" would operate the same way)
> I have added isOlderFile() methods to FileUtils and propose that AgeFileFilter is changed to the following:
>     if (acceptOlder) {
>         return FileUtils.isFileOlder(file, cutoff);
>     } else {
>         return FileUtils.isFileNewer(file, cutoff);
>     }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


[jira] Commented: (IO-89) Inconsistency in SizeFileFilter and AgeFileFilter implementations

Posted by "Stephen Colebourne (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/IO-89?page=comments#action_12423451 ] 
            
Stephen Colebourne commented on IO-89:
--------------------------------------

I'm not sure I'm entirely convinced of the need for this. But if it is going to be done it should use an enumerated type (pre JDK1.5) as per the IOCase class.

> Inconsistency in SizeFileFilter and AgeFileFilter implementations
> -----------------------------------------------------------------
>
>                 Key: IO-89
>                 URL: http://issues.apache.org/jira/browse/IO-89
>             Project: Commons IO
>          Issue Type: Bug
>          Components: Filters
>    Affects Versions: 1.2
>            Reporter: Niall Pemberton
>            Priority: Minor
>             Fix For: 1.3
>
>
> Theres an inconsistency (bug?) in the implementation of SizeFileFilter and AgeFileFilter.
> In SizeFileFilter, using an "acceptLarger" parameter of true actually accepts files with a size equal to and larger, whereas
> specifying an "acceptLarger" parameter of false only accepts smaller files.
> The same is true for AgeFileFilter, using an "acceptOlder" parameter of true actually accepts files either the same age or older, whereas
> specifying an "acceptOlder" parameter of false only accepts newer files.
> A big benefit of resolving these inconsistencies would mean that creating filters for any condition (i.e. <, >, <=, >= or =) becomes
> alot easier. For example if the AgeFileFilter did only do either newer or older, then creating a filters for "the same age or older"
> or "the same age or younger" could be done in the following way:
>     IOFileFilter equalOlder   = new NotFileFilter(new AgeFileFilter(cutoff, false));
>     IOFileFilter equalYounger = new NotFileFilter(new AgeFileFilter(cutoff, true));
> For SizeFileFilter I propose changing the logic to the following:
>     if (acceptLarger) {
>         return file.length() >= size;
>     } else {
>         return file.length() <= size;
>     }
> (This would mean that "new SizeFileFilter(cutoff)" would operate the same way)
> I have added isOlderFile() methods to FileUtils and propose that AgeFileFilter is changed to the following:
>     if (acceptOlder) {
>         return FileUtils.isFileOlder(file, cutoff);
>     } else {
>         return FileUtils.isFileNewer(file, cutoff);
>     }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


[jira] Commented: (IO-89) Inconsistency in SizeFileFilter and AgeFileFilter implementations

Posted by "Stephen Colebourne (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/IO-89?page=comments#action_12441574 ] 
            
Stephen Colebourne commented on IO-89:
--------------------------------------

I can see a javadoc fix as being valid here, but I don't believe we can change => to >. I also wonder how often the full variety of operators is needed.

I'm happy if you want to propose out a complete and more advanced solution with all the operators, but for now, I think we should just javadoc this (including the method params if possible).


> Inconsistency in SizeFileFilter and AgeFileFilter implementations
> -----------------------------------------------------------------
>
>                 Key: IO-89
>                 URL: http://issues.apache.org/jira/browse/IO-89
>             Project: Commons IO
>          Issue Type: Bug
>          Components: Filters
>    Affects Versions: 1.2
>            Reporter: Niall Pemberton
>            Priority: Minor
>             Fix For: 1.3
>
>
> Theres an inconsistency (bug?) in the implementation of SizeFileFilter and AgeFileFilter.
> In SizeFileFilter, using an "acceptLarger" parameter of true actually accepts files with a size equal to and larger, whereas
> specifying an "acceptLarger" parameter of false only accepts smaller files.
> The same is true for AgeFileFilter, using an "acceptOlder" parameter of true actually accepts files either the same age or older, whereas
> specifying an "acceptOlder" parameter of false only accepts newer files.
> A big benefit of resolving these inconsistencies would mean that creating filters for any condition (i.e. <, >, <=, >= or =) becomes
> alot easier. For example if the AgeFileFilter did only do either newer or older, then creating a filters for "the same age or older"
> or "the same age or younger" could be done in the following way:
>     IOFileFilter equalOlder   = new NotFileFilter(new AgeFileFilter(cutoff, false));
>     IOFileFilter equalYounger = new NotFileFilter(new AgeFileFilter(cutoff, true));
> For SizeFileFilter I propose changing the logic to the following:
>     if (acceptLarger) {
>         return file.length() >= size;
>     } else {
>         return file.length() <= size;
>     }
> (This would mean that "new SizeFileFilter(cutoff)" would operate the same way)
> I have added isOlderFile() methods to FileUtils and propose that AgeFileFilter is changed to the following:
>     if (acceptOlder) {
>         return FileUtils.isFileOlder(file, cutoff);
>     } else {
>         return FileUtils.isFileNewer(file, cutoff);
>     }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


[jira] Commented: (IO-89) Inconsistency in SizeFileFilter and AgeFileFilter implementations

Posted by "Rahul Akolkar (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/IO-89?page=comments#action_12423130 ] 
            
Rahul Akolkar commented on IO-89:
---------------------------------

Agreed, thanks for your time. My only comment is since FileUtils.isFileNewer/Older are exclusive, perhaps we should have SizeFileFilter be exclusive as well (so < instead of <= etc.), that way there is consistency across filters as well.


> Inconsistency in SizeFileFilter and AgeFileFilter implementations
> -----------------------------------------------------------------
>
>                 Key: IO-89
>                 URL: http://issues.apache.org/jira/browse/IO-89
>             Project: Commons IO
>          Issue Type: Bug
>          Components: Filters
>    Affects Versions: 1.2
>            Reporter: Niall Pemberton
>            Priority: Minor
>             Fix For: 1.3
>
>
> Theres an inconsistency (bug?) in the implementation of SizeFileFilter and AgeFileFilter.
> In SizeFileFilter, using an "acceptLarger" parameter of true actually accepts files with a size equal to and larger, whereas
> specifying an "acceptLarger" parameter of false only accepts smaller files.
> The same is true for AgeFileFilter, using an "acceptOlder" parameter of true actually accepts files either the same age or older, whereas
> specifying an "acceptOlder" parameter of false only accepts newer files.
> A big benefit of resolving these inconsistencies would mean that creating filters for any condition (i.e. <, >, <=, >= or =) becomes
> alot easier. For example if the AgeFileFilter did only do either newer or older, then creating a filters for "the same age or older"
> or "the same age or younger" could be done in the following way:
>     IOFileFilter equalOlder   = new NotFileFilter(new AgeFileFilter(cutoff, false));
>     IOFileFilter equalYounger = new NotFileFilter(new AgeFileFilter(cutoff, true));
> For SizeFileFilter I propose changing the logic to the following:
>     if (acceptLarger) {
>         return file.length() >= size;
>     } else {
>         return file.length() <= size;
>     }
> (This would mean that "new SizeFileFilter(cutoff)" would operate the same way)
> I have added isOlderFile() methods to FileUtils and propose that AgeFileFilter is changed to the following:
>     if (acceptOlder) {
>         return FileUtils.isFileOlder(file, cutoff);
>     } else {
>         return FileUtils.isFileNewer(file, cutoff);
>     }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org