commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel F. Savarese" <...@savarese.org>
Subject Re: [io] Re: FileNameFilter with Regex search ?
Date Fri, 11 Jun 2004 00:42:36 GMT

In message <D1639D06CFBD014F87F3978DA7038B93CAC4A8@ns1017.SSSI.seagull.nl>, "Ga
ry Gregory" writes:
>Yes, please, no wheel reinvention ;-)

I guess where I was going with my comment was that maybe the oro
.io package should be pulled out of oro and placed in commons-io.
Presumably, the filter being proposed was implemented with J2SE 1.4,
which would break pre-1.4 compatibility if such is required by commons-io.
Having a dependency on oro and supporting pre-1.4 J2SE SDK's seems a
little better than not supporting pre-1.4 J2SE SDK's.

But you can have your cake and eat it too.  J2SE 1.4 can also be supported
and you can have a single regexp filter class that can be told what pattern
matching engine to use.  I just changed org.apache.oro.io.RegexFilenameFilter
from being an abstract class to a concrete class and added the following
two constructors on the oro head branch:

  public RegexFilenameFilter(PatternMatchingEngine engine) {
    _cache   = new PatternCacheLRU(engine.createCompiler());
    _matcher = engine.createMatcher();
  }

  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();
  }

Filename filtering is one of those uses that justifies having pluggable
pattern matching engines.  If anyone actually cares, I (or someone
else; nudge, nudge) can move forward with wrapping J2SE 1.4 java.util.regex
and Jakarta regexp with PatternMatchingEngine implementations and a decision
can be made as to whether commons-io is willing to have a dependency on oro
in order to adopt a generic regex filename filter class (it obviates the need
for separate glob/wildcard, perl, whatever filtering classes).  And if no
one cares, then no worries either.

daniel



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


Mime
View raw message