From: "Duncan Harris" <[EMAIL PROTECTED]>

This is getting to be more of a ant-dev 
question, but anyway...

> [EMAIL PROTECTED] (Magesh Umasankar) wrote:
> 
> > In Ant's CVS tree (1.5Alpha), I have recently
> > committed a set of FilterReaders.  Please take
> > a look at it.  IMHO, your task must instead be
> > implemented as a filterreader that can be
> > passed to multiple tasks like <copy>, <move>,
> > <loadfile>, etc.
> 
> I had a look at the docs for this.
> I could see how to convert this to a custom filter.
> 

Very cool.

> I see you already have one for Java comment stripping.
> The JavaScript one presumably very similar, though not
> quite the same. However I looked at the code for StripJavaComments
> as an example and it is wrong, e.g. k=a/b converts to k=ab
> 

Hmm.  I just reused some code that was in
Ant's codebase earlier.  Thanks for spotting
this bug.  I will get it fixed.

> What about doing it with a regexp though?
> Is there any way to use a general regexp substitution
> as a filter? I couldn't see how off hand. 

Yes, you definitely can do regexp
substitution.  The <containsregexp> filter
currently gets lines that contain a regexp;
it should not be too difficult to do
<replaceregexp>, once you take a look at how
<containsregexp> is done.

> It needs to
> be whole file substitute, not line by line.
> 

There are two methods in BaseFilterReader:
readLine and readFully:
readLine will return the next line, while
readFully will read the entire stream and
return it as a string.  You would use
the readFully method and do regexp
substitution on the returned string...

For an example of how readFully is used, 
take a look at the <expandproperties> filter.

> Duncan Harris

Cheers,
Magesh

*************************************************
*  Politician: One who shakes your hand before  *
*  elections and your confidence after.         *
*************************************************



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to