jakarta-oro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject cvs commit: jakarta-oro/src/java/org/apache/oro/io AwkFilenameFilter.java GlobFilenameFilter.java Perl5FilenameFilter.java RegexFilenameFilter.java
Date Fri, 11 Jun 2004 00:35:14 GMT
dfs         2004/06/10 17:35:14

  Modified:    src/java/org/apache/oro/io AwkFilenameFilter.java
                        GlobFilenameFilter.java Perl5FilenameFilter.java
                        RegexFilenameFilter.java
  Log:
  Changed RegexFilenameFilter from being a abstract to being concrete
  and added constructors allowing the use of a PatternMatcherEngine
  or a PaternMatcherEngineFactory key to initialize the matcher.
  Adjusted the documentation to Awk, Glob, and Perl5 filters to indicate
  they are convenience classes.  Should probably just deprecate them and
  say to use RegexFilenameFilter(String key) instead.
  
  Revision  Changes    Path
  1.9       +4 -4      jakarta-oro/src/java/org/apache/oro/io/AwkFilenameFilter.java
  
  Index: AwkFilenameFilter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-oro/src/java/org/apache/oro/io/AwkFilenameFilter.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- AwkFilenameFilter.java	13 Feb 2004 22:01:59 -0000	1.8
  +++ AwkFilenameFilter.java	11 Jun 2004 00:35:14 -0000	1.9
  @@ -26,9 +26,9 @@
   import org.apache.oro.text.*;
   
   /**
  - * AwkFilenameFilter is a RegexFilenameFilter subclass that filters on Awk
  - * regular expressions as implemented by the org.apache.oro.text.awk package,
  - * which is required to use this class.
  + * AwkFilenameFilter is a convenience class that subclasses RegexFilenameFilter
  + * and filters on Awk regular expressions as implemented by the
  + * org.apache.oro.text.awk package, which is required to use this class.
    *
    * @version @version@
    * @since 1.0
  
  
  
  1.9       +5 -4      jakarta-oro/src/java/org/apache/oro/io/GlobFilenameFilter.java
  
  Index: GlobFilenameFilter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-oro/src/java/org/apache/oro/io/GlobFilenameFilter.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- GlobFilenameFilter.java	13 Feb 2004 22:01:59 -0000	1.8
  +++ GlobFilenameFilter.java	11 Jun 2004 00:35:14 -0000	1.9
  @@ -25,9 +25,10 @@
   import org.apache.oro.text.*;
   
   /**
  - * GlobFilenameFilter is a RegexFilenameFilter subclass that filters on Glob
  - * regular expressions as implemented by the org.apache.oro.text package,
  - * which is required to use this class.
  + * GlobFilenameFilter is a convenience class that subclasses
  + * RegexFilenameFilter and filters on Glob regular expressions
  + * as implemented by the org.apache.oro.text package, which is
  + * required to use this class.
    *
    * @version @version@
    * @since 1.0
  
  
  
  1.9       +5 -4      jakarta-oro/src/java/org/apache/oro/io/Perl5FilenameFilter.java
  
  Index: Perl5FilenameFilter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-oro/src/java/org/apache/oro/io/Perl5FilenameFilter.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Perl5FilenameFilter.java	13 Feb 2004 22:01:59 -0000	1.8
  +++ Perl5FilenameFilter.java	11 Jun 2004 00:35:14 -0000	1.9
  @@ -26,9 +26,10 @@
   
   
   /**
  - * Perl5FilenameFilter is a RegexFilenameFilter subclass that filters on Perl5
  - * regular expressions as implemented by the org.apache.oro.text.regex package,
  - * which is required to use this class.
  + * Perl5FilenameFilter is a convenience class that subclasses
  + * RegexFilenameFilter and filters on Perl5 regular expressions as
  + * implemented by the org.apache.oro.text.regex package, which is
  + * required to use this class.
    *
    * @version @version@
    * @since 1.0
  
  
  
  1.11      +42 -6     jakarta-oro/src/java/org/apache/oro/io/RegexFilenameFilter.java
  
  Index: RegexFilenameFilter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-oro/src/java/org/apache/oro/io/RegexFilenameFilter.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- RegexFilenameFilter.java	13 Feb 2004 22:01:59 -0000	1.10
  +++ RegexFilenameFilter.java	11 Jun 2004 00:35:14 -0000	1.11
  @@ -26,7 +26,9 @@
   
   /**
    * RegexFilenameFilter is the base class for a set of FilenameFilter
  - * implementations that filter based on a regular expression.
  + * implementations that filter based on a regular expression.  It
  + * is also a generic filter implementation that can use any regular
  + * expression engine represented by a {@link PatternMatchingEngine}.
    *
    * @version @version@
    * @since 1.0
  @@ -34,9 +36,7 @@
    * @see AwkFilenameFilter
    * @see GlobFilenameFilter
    */
  -public abstract class RegexFilenameFilter implements FilenameFilter,
  -						     FileFilter
  - {
  +public class RegexFilenameFilter implements FilenameFilter, FileFilter {
     PatternCache   _cache;
     PatternMatcher _matcher;
     Pattern _pattern;
  @@ -49,7 +49,7 @@
     }
   
     RegexFilenameFilter(PatternCache cache, PatternMatcher matcher,
  -		      String regex, int options)
  +                      String regex, int options)
     {
       _cache   = cache;
       _matcher = matcher;
  @@ -58,6 +58,42 @@
   
     RegexFilenameFilter(PatternCache cache, PatternMatcher matcher) {
       this(cache, matcher, "");
  +  }
  +
  +  /**
  +   * Creates a new RegexFilenameFilter using the supplied
  +   * {@link PatternMatchingEngine}.
  +   *
  +   * @param engine The {@link PatternMatchingEngine} to use for pattern
  +   *               matching.
  +   */
  +  public RegexFilenameFilter(PatternMatchingEngine engine) {
  +    _cache   = new PatternCacheLRU(engine.createCompiler());
  +    _matcher = engine.createMatcher();
  +  }
  +
  +  /**
  +   * Creates a new RegexFilenameFilter using the supplied engine key to
  +   * create a {@link PatternMatchingEngine} using
  +   * the {@link PatternMatchingEngineFactory} class.
  +   *
  +   * @param engineKey One of the {@link PatternMatchingEngineFactory} engine
  +   *                  keys.
  +   * @throws IllegalArgumentException
  +   */
  +  public RegexFilenameFilter(String engineKey) 
  +    throws IllegalArgumentException
  +  {
  +    PatternMatchingEngineFactory factory = new PatternMatchingEngineFactory();
  +    PatternMatchingEngine engine = factory.get(engineKey);
  +
  +    if(engine == null)
  +      throw
  +        new IllegalArgumentException("Unsupported PatternMatchingEngine type: "
  +                                     + engineKey);
  +    
  +    _cache   = new PatternCacheLRU(engine.createCompiler());
  +    _matcher = engine.createMatcher();
     }
   
     /**
  
  
  

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


Mime
View raw message