[ http://issues.apache.org/jira/browse/IO-66?page=comments#action_12442263 
] 
            
Guillaume Coté commented on IO-66:
----------------------------------

>From the sun website 

J2SE 1.3.1 has begun the Sun End of Life (EOL) process. The EOL transition 
period is from Oct 25, 2004, until the General Availability (GA) of the next 
Java version, Java SE 6. With this notice, customers are strongly encouraged to 
migrate to the current release, J2SE 5.0.  »  Read More

During this EOL transition period, the products will continue to be supported 
per existing customer support agreements. After the GA of Java SE 6, post EOL 
support will be available as follows:

    * On Solaris 8:
      With a valid Sun software support contract, J2SE 1.3.1 will continue to 
be supported until the end of the Solaris 8 five year Vintage Support Period.
    * On Windows and Linux
      A paid Java Vintage Support Offering will be available, contact your Sun 
sales representative for details.

For developer needs, all products that have completed the EOL transition period 
will be moved to the Archive area.

from http://java.sun.com/j2se/1.3/index.jsp

I suggest that the project move to version 1.4 after the release Java SE 6, 
which is already in beta.

> [IO] FilenameFilter that uses regular expressions (upload)
> ----------------------------------------------------------
>
>                 Key: IO-66
>                 URL: http://issues.apache.org/jira/browse/IO-66
>             Project: Commons IO
>          Issue Type: Improvement
>          Components: Filters
>         Environment: Operating System: Windows XP
> Platform: All
>            Reporter: analogue
>            Priority: Minor
>             Fix For: 1.4
>
>
> I was in need of a FilenameFilter that observed case-sensetivity and couldn't
> find anything in the existing commons-io library to meet this requirement. So,
> I've thrown together RegexFileFilter and an accompanying unit test to fill the
> void. Please add/apply to commons-io as necessary.
> -sp
> I don't see a way to attach files so heres the cut-n-paste:
> ================================================================================
> /*
>  * Copyright 2002-2004 The Apache Software Foundation.
>  * 
>  * Licensed under the Apache License, Version 2.0 (the "License");
>  * you may not use this file except in compliance with the License.
>  * You may obtain a copy of the License at
>  * 
>  *      http://www.apache.org/licenses/LICENSE-2.0
>  * 
>  * Unless required by applicable law or agreed to in writing, software
>  * distributed under the License is distributed on an "AS IS" BASIS,
>  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
>  * See the License for the specific language governing permissions and
>  * limitations under the License.
>  */
> package org.apache.commons.io.filefilter;
> import java.io.File;
> import java.io.IOException;
> import org.apache.commons.io.filefilter.AbstractFileFilter;
> import org.apache.regexp.RE;
> import org.apache.regexp.RESyntaxException;
> /**
>  * Filters files based on a regular expression that is matched against the 
>  * entire filename (including drive, path, and name). Of particular note about
>  * this filter is the ability to express case-sensetivity. 
>  *  
>  * <p>
>  * For example, to retrieve and print all files that contain the string
>  * <code>"xyz"</code> in the current directory, the regular expression 
>  * <code>".*xyz.*"</code> can be used:
>  *
>  * <pre>
>  * File dir = new File(".");
>  * String[] files = dir.list(new RegexFileFilter(".*xyz.*", true));
>  * for (int i = 0; i &lt; files.length; i++) {
>  *     System.out.println(files[i]);
>  * }
>  * </pre>
>  * 
>  * To match using case-insensetivity, 
>  * <code>new RegexFileFilter(".*xyz.*", false)</code> would be appropriate.
>  * 
>  * @author Semir Patel
>  */
> public class RegexFileFilter extends AbstractFileFilter {
>     
>     
> //--------------------------------------------------------------------------
>     // Fields
>     
> //--------------------------------------------------------------------------
>     
>     /** 
>      * Regular expression matcher. 
>      */
>     private RE regExp;
>     
>     
> //--------------------------------------------------------------------------
>     // Constructors
>     
> //--------------------------------------------------------------------------
>     
>     /**
>      * Creates a file filter that applies a regular expression to the entire
>      * path + name of a file's absolute location.
>      * 
>      * @param regExp Regular expression to match.
>      * @param matchCase Set to true to match using case sensetivity, false 
>      *        otherwise.
>      * @throws RESyntaxException if the regular expression is invalid.
>      */
>     public RegexFileFilter(String regExp, boolean matchCase)
>         throws RESyntaxException {
>         
>         this.regExp = new RE(regExp, 
>             matchCase ? RE.MATCH_NORMAL: RE.MATCH_CASEINDEPENDENT);        
>     }
>     
> //--------------------------------------------------------------------------
>     // Overrides AbstractFileFilter
>     
> //--------------------------------------------------------------------------
>     
>     /**
>      * Accepts by matching the filename against a regular expression.
>      * 
>      * @throws RuntimeException if an IOException occurs.
>      * @see org.apache.commons.io.filefilter.AbstractFileFilter#accept(
>      *      java.io.File)
>      */
>     public boolean accept(File file) {
>         
>         try {
>             return regExp.match(file.getCanonicalPath());
>         }
>         catch (IOException e) {
>             
>             // TODO: Follow commons-io existing practice...
>             throw new RuntimeException(e);
>         }
>     }
> }
> ==========================================================================
> /*
>  * Copyright 2002-2004 The Apache Software Foundation.
>  * 
>  * Licensed under the Apache License, Version 2.0 (the "License");
>  * you may not use this file except in compliance with the License.
>  * You may obtain a copy of the License at
>  * 
>  *      http://www.apache.org/licenses/LICENSE-2.0
>  * 
>  * Unless required by applicable law or agreed to in writing, software
>  * distributed under the License is distributed on an "AS IS" BASIS,
>  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
>  * See the License for the specific language governing permissions and
>  * limitations under the License.
>  */
> package org.apache.commons.io.filefilter;
> import java.io.File;
> import junit.framework.TestCase;
> import junit.textui.TestRunner;
> import org.apache.commons.io.FileUtils;
> import org.apache.regexp.RESyntaxException;
> /**
>  * Unit test for [EMAIL PROTECTED] RegexFileFilterTest}.
>  * 
>  * @author Semir Patel
>  */
> public class RegexFileFilterTest extends TestCase {
>     
>     
> //--------------------------------------------------------------------------
>     // Constants
>     
> //--------------------------------------------------------------------------
>     /**
>      * Temporary file names that unit tests will use for verification.
>      */
>     private static final String[] FILENAMES = new String[] {
>         "EVENT.java",
>     };
>     
> //--------------------------------------------------------------------------
>     // Fields
>     
> //--------------------------------------------------------------------------
>     
>     /** 
>      * Test directory for filtering files. 
>      */
>     private File testDir;
>     
>     
> //--------------------------------------------------------------------------
>     // Main
>     
> //--------------------------------------------------------------------------
>     
>     /** 
>      * Entrypoint.
>      * 
>      * @param args None recognized.
>      */
>     public static void main(String[] args)
>     {
>         TestRunner.run(RegexFileFilterTest.class);
>     }
>     
> //--------------------------------------------------------------------------
>     // Overrides TestCase
>     
> //--------------------------------------------------------------------------
>     
>     /** 
>      * Create a temporary directory with files to use for testing.
>      */
>     protected void setUp() throws Exception {
>         
>         File tmpDir = new File(System.getProperty("java.io.tmpdir"));
>         testDir = File.createTempFile("temp", "", tmpDir);
>         testDir.delete();
>         
>         assertTrue(
>             "test dir creation failed for " + testDir.getCanonicalPath(), 
>             testDir.mkdirs()); 
>         
>         for (int i = 0; i < FILENAMES.length; i++)
>             FileUtils.writeStringToFile(
>                 new File(testDir, FILENAMES[i]), "testing" + i, "UTF-8");
>     }
>     
>     /**
>      * Clean up temporary directory.
>      */
>     protected void tearDown() throws Exception {
>         FileUtils.forceDelete(testDir);
>         super.tearDown();
>     }
>    
>     
> //--------------------------------------------------------------------------
>     // Case Insensetive 
>     
> //--------------------------------------------------------------------------
>     
>     public void testAccept_CaseInsensetive_NotFound() throws Exception {
>         IOFileFilter filter = new RegexFileFilter("bogus", false);
>         
>         String matches[] = testDir.list(filter);
>         assertEquals("No matches should have been found", 0, matches.length);
>     } 
>     
>     public void testAccept_CaseInsensetive_CaseMatch() throws Exception {
>         IOFileFilter filter = new RegexFileFilter("EVENT", false);
>         
>         String matches[] = testDir.list(filter);
>         assertEquals("One match should have been found", 1, matches.length);
>         assertEquals("One match should have been found", "EVENT.java", 
> matches[0]);
>     } 
>     
>     public void testAccept_CaseInsensetive_CaseMismatch() throws Exception {
>         IOFileFilter filter = new RegexFileFilter("event", false);
>         
>         String matches[] = testDir.list(filter);
>         assertEquals("One match should have been found", 1, matches.length);
>         assertEquals("One match should have been found", "EVENT.java", 
> matches[0]);
>     }
>     
>     
> //--------------------------------------------------------------------------
>     // Case Sensetive 
>     
> //--------------------------------------------------------------------------
>     
>     public void testAccept_CaseSensetive_NotFound() throws Exception {
>         IOFileFilter filter = new RegexFileFilter("bogus", true);
>         
>         String matches[] = testDir.list(filter);
>         assertEquals("No matches should have been found", 0, matches.length);
>     } 
>     
>     public void testAccept_CaseSensetive_ExactMatch() throws Exception {
>         IOFileFilter filter = new RegexFileFilter("EVENT", true);
>         
>         String matches[] = testDir.list(filter);
>         assertEquals("One match should have been found", 1, matches.length);
>         assertEquals("One match should have been found", "EVENT.java", 
> matches[0]);
>     } 
>     
>     public void testAccept_CaseSensetive_CaseMismatch() throws Exception {
>         IOFileFilter filter = new RegexFileFilter("event", true);
>         
>         String matches[] = testDir.list(filter);
>         assertEquals("No matches should have been found", 0, matches.length);
>     } 
>     
>     
> //--------------------------------------------------------------------------
>     // Negative Unit Tests
>     
> //--------------------------------------------------------------------------
>     
>     /**
>      * Make sure constructor blows up on invalid regular expressions.
>      */
>     public void testConstructor_Invalid_RegExp() {
>         
>         try {
>             RegexFileFilter filter = new RegexFileFilter("*", true);
>             fail("Expected exception on invalid regular expression");
>         }
>         catch (RESyntaxException rese) {
>             // Success
>         }
>     }
> }

-- 
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to