tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <bay...@generationjava.com>
Subject Re: Bay or Glen, String Replace tag broken
Date Fri, 07 Dec 2001 15:51:17 GMT


I've fixed it by copying over a previous rewrite from Jakarta Commons
where the code lives inside the util sub-project's StringUtils. Sadly that
code is still in a sandbox and I'm hesitant to make String-taglib
dependant on code that is still living in a sandbox.

[Then I'll need to find out how to go about making the taglib dependant on
 Commons]

The rewrite basically involved switching it to using a StringBuffer for
speed.

Bay

> On Fri, 7 Dec 2001, Neuman, Ben J. , AFIS-HQ/IRM wrote:
>
> > Hi!
> > The String tag replace is broken. It looks like you need to change the
> > StringW class method:
> >
> > static public String replaceString(String text, String repl, String with,
> > int n) {
> >         int idx = 0;
> >         while( (idx = text.indexOf(repl)) != -1) {
> >             text = text.substring(0,idx) + with +
> > text.substring(idx+repl.length() );
> >             idx += with.length();    // jump beyond replacement
> >             n--;
> >             if(n == 0) {
> >                 break;
> >             }
> >         }
> >         return text;
> >     }
> >
> > to:
> >
> > static public String replaceString(String text, String repl, String with,
> > int n) {
> >         int idx = 0;
> >         while( (idx = text.indexOf(repl, idx)) != -1) {
> >             text = text.substring(0,idx) + with +
> > text.substring(idx+repl.length() );
> >             idx += with.length();    // jump beyond replacement
> >             n--;
> >             if(n == 0) {
> >                 break;
> >             }
> >         }
> >         return text;
> >     }
> >
> > If this is alleady done, please ignore. Just trying to help.
> > Thanks,
> > Ben
> >
> >
> > --
> > To unsubscribe, e-mail:   <mailto:taglibs-user-unsubscribe@jakarta.apache.org>
> > For additional commands, e-mail: <mailto:taglibs-user-help@jakarta.apache.org>
> >
> >
>
>
> --
> To unsubscribe, e-mail:   <mailto:taglibs-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:taglibs-user-help@jakarta.apache.org>
>
>


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


Mime
View raw message