ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Koegel, Michael" <Michael.Koe...@partner.commerzbank.com>
Subject AW: FilterChains - grep and sed
Date Tue, 10 Dec 2002 11:57:30 GMT
Hi,

perhaps you could use the Java Regexp Plugin API to avoid dependeny on ORO
and give the user a chance to choose his favorit regex package.
See http://www-106.ibm.com/developerworks/web/library/wa-regexp.html and
http://sourceforge.net/projects/regexpplugin for details.

Note! I didn't try this out, but it sounds like a good idea.

--MK

-----Urspr√ľngliche Nachricht-----
Von: Scott Stirling [mailto:scottstirling@rcn.com]
Gesendet am: Montag, 9. Dezember 2002 06:02
An: Ant Users List
Betreff: RE: FilterChains - grep and sed

Continuing in this thought of using FilterChains to implement sed, grep, tr,
etc. . . . I've been thinking about it between other tasks, and tonight I
sat and looked at the existing filter chains and the ORO library.

I don't know if it's allowed to have something like jakarta-oro be a
dependency in the core tasks, types, etc.  But if that library was allowed
in there, several of the existing built-in FilterReaders could be eliminated
(if desired), in place of a more flexible, general purpose way of performing
pattern-based file stream transformations.

LineContains, LineContainsRegExp, ReplaceTokens, StripLineBreaks,
StripLineComments, TabsToSpaces can be thought of as a small library of
fixed substitutions or transformations.  In UNIX these could all be done
with grep, sed or tr (in more than one way), for example:

LineContains       = grep string file
LineContainsRegExp = grep 'regex' file
ReplaceTokens      = sed 's/pattern/value/g' file
StripLineBreaks    = tr -d '\r\n' < file
StripLineComments  = sed '/pattern/d' file
TabsToSpaces       = tr '\t' '        ' < file

The Jakarta ORO library provides a very graceful API for matching and
replacing patterns.  It's flexibility would make the whole FilterChain
concept extremely extensible and flexible with minimal code writing.  My
only question at this point is how much trouble it would be to use it in the
context of a FilterReader's read() method, where everything is based on
reading a line and returning ints, one character at a time.

Scott Stirling





--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>

--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message