commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Cohen <sco...@javactivity.org>
Subject Re: Incorrect documentation of FTP task [net]
Date Wed, 18 Feb 2004 12:32:55 GMT
This is all true, Daniel, but I think the initial motivation of Dominique 
Devienne was to REMOVE the requirement that oro be on ant's runtime classpath 
when running the ftp taks, not to make oro a central dispatch point for other 
regex processors.  In case it wasn't clear, I don't really support Dominique 
on this, unless it can be done "right" which is not quite so trivial becasue 
the "wrong" ways  simply replace the requirement to use one jar with the 
requirement to use another.  

At the end of the day, is it that hard to put a jar on your classpath?




On Wednesday 18 February 2004 1:05 am, Daniel F. Savarese wrote:
> In message <200402172104.11737.scohen@javactivity.org>, Steve Cohen writes:
> >You've built an interface to encapsulate the choice in regex
> > implementations with automatic checking.  Sweet!  Perhaps we could port
> > it to commons-net -
>
> ...
>
> >Perhaps this checker mechanism could be ported to commons (a la
> >commons-logging).  Then it could be available to other clients, in
> >particular, to commons clients.  But of course then we'd be requiring yet
>
> ...
>
> >I think we ought to think seriously about what we are doing here before we
> >rush into coding anything like this.
>
> *sigh*  No one ever brings these things up on the oro or regexp mailing
> lists.  This is one of those really easy things to do with oro, which
> most folks don't realize implements three different regular expression
> engines.  I know I promised to do the vpp-based conditional compilation
> to provide a J2ME/JDK1.1 compatible version of oro, but I just haven't
> found the time.  This however is easy stuff.  I just added two new
> interfaces to org.apache.oro.text.regex: PatternMatchingEngine and
> PatternCompilerOptions.  I implemented these interfaces for the
> Perl5, Awk, and Glob engines.  I then wrote a PatternMatchingEngineFactory
> class to generate engines.  You can put the J2SE 1.4 detection code
> in there and add an org.apache.oro.text.java package that wraps
> java.util.regex.  All you have to do is implement PatternMatcher,
> PatternCompiler, and Pattern for J2SE 1.4.  If someone will step up
> to do this, I'm sure the PMC will grant commit access immediately.
> I'd actually rather if all of jakarta had commit access to oro for
> this very kind of situation.  When you don't have commit access, there
> is sometimes a tendency to reinvent the wheel.
>
> I've appended a modified version of the grep example that shows how
> you might pick an engine based on a set of preferences.  At any rate,
> I very much thing oro is the place for generic regular expression
> engine support since it was designed with that in mind from the
> start (although the pattern compilation options could have been
> abstracted better at its genesis).  I invite anyone and everyone to
> do a checkout of the latest jakarta-oro files in CVS and start
> improving my 30 minute hack.
>
> daniel
>
>
> package examples;
>
> import java.io.*;
> import java.util.*;
>
> import org.apache.oro.text.*;
> import org.apache.oro.text.regex.*;
>
> /**
>  * This is a no-frills implementation of grep that demos the use of
>  * PatternMatchingEngineFactory to choose different
>  * regular expression engines.  It performs case insensitive matching
>  * to demonstrate the use of the PatternCompilerOptions interface.
>  *
>  * @version @version@
>  */
> public final class engineExample {
>   static int _file = 0;
>
>   static final String[] _preferences = {
>     PatternMatchingEngineFactory.JAVA_KEY,
>     PatternMatchingEngineFactory.PERL5_KEY,
>     PatternMatchingEngineFactory.POSIX_KEY,
>     PatternMatchingEngineFactory.AWK_KEY,
>     PatternMatchingEngineFactory.GLOB_KEY
>   };
>
>   // args[] is declared final so that Inner Class may reference it.
>   public static final void main(final String[] args) {
>     PatternMatchingEngineFactory factory;
>     PatternMatchingEngine engine = null;
>     PatternCompiler compiler;
>     PatternCompilerOptions options;
>     PatternMatcher matcher;
>     MatchActionProcessor processor;
>     int mask;
>
>     if(args.length < 2) {
>       System.err.println("Usage: grep <pattern> <filename> ...");
>       System.exit(1);
>     }
>
>     factory = new PatternMatchingEngineFactory();
>
>     // Demonstration of choosing engine based on preferences.
>     for(int i = 0; i < _preferences.length; ++i) {
>       if(factory.containsKey(_preferences[i])) {
>         engine = factory.get(_preferences[i]);
>         break;
>       }
>     }
>
>     if(engine == null)
>       engine = factory.get(PatternMatchingEngineFactory.DEFAULT_KEY);
>
>     compiler = engine.createCompiler();
>     matcher  = engine.createMatcher();
>     options  = engine.getOptions();
>     mask     = options.getMask(PatternCompilerOptions.CASE_INSENSITIVE);
>     processor = new MatchActionProcessor(compiler, matcher);
>
>     try {
>       if(args.length > 2) {
> 	// Print filename before line if more than one file is specified.
> 	// Rely on file to point to current file being processed.
> 	processor.addAction(args[0], mask, new MatchAction() {
> 	  public void processMatch(MatchActionInfo info) {
> 	    info.output.println(args[_file] + ":" + info.line);
> 	  }
>         });
>       } else {
> 	// We rely on the default action of printing matched
> 	// lines to the given OutputStream
> 	processor.addAction(args[0], mask);
>       }
>
>       for(_file = 1; _file < args.length; _file++)
> 	processor.processMatches(new FileInputStream(args[_file]), System.out);
>
>     } catch(MalformedPatternException e) {
>       System.err.println("Bad pattern.");
>       e.printStackTrace();
>       System.exit(1);
>     } catch(IOException e) {
>       System.err.println("Error opening or reading " + args[_file]);
>       e.printStackTrace();
>       System.exit(1);
>     }
>   }
>
> }
>
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org


---------------------------------------------------------------------
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