Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 65612 invoked from network); 9 Jul 2005 09:38:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 9 Jul 2005 09:38:23 -0000 Received: (qmail 32162 invoked by uid 500); 9 Jul 2005 09:38:20 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 32132 invoked by uid 500); 9 Jul 2005 09:38:20 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 32114 invoked by uid 99); 9 Jul 2005 09:38:20 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 09 Jul 2005 02:38:20 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [194.25.134.85] (HELO mailout11.sul.t-online.com) (194.25.134.85) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 09 Jul 2005 02:38:18 -0700 Received: from fwd35.aul.t-online.de by mailout11.sul.t-online.com with smtp id 1DrBmq-0000Z1-03; Sat, 09 Jul 2005 11:38:16 +0200 Received: from [192.168.0.1] (GulocwZErey+u-ybcvLNtwfJBUl+Zv6wWV6I0Xe1olJECgCW-qmG6g@[84.174.124.17]) by fwd35.sul.t-online.de with esmtp id 1DrBml-1t4i0W0; Sat, 9 Jul 2005 11:38:11 +0200 Message-ID: <42CF9B0A.3040507@t-online.de> Date: Sat, 09 Jul 2005 11:38:18 +0200 From: Oliver Heger User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Jakarta Commons Developers List Subject: Re: [lang] text.Interpolation, on to 2.2 References: <42CC6501.6090907@btopenworld.com> In-Reply-To: <42CC6501.6090907@btopenworld.com> X-Enigmail-Version: 0.89.6.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-ID: GulocwZErey+u-ybcvLNtwfJBUl+Zv6wWV6I0Xe1olJECgCW-qmG6g X-TOI-MSGID: 413c5db4-28c2-4872-8360-4788298f9818 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Some comments inline... Stephen Colebourne wrote: > Gary Gregory wrote: > >>> The source of values for the VariableFormat class is only allowed to be >>> a Map. I'm not sure if people will want other types of data sources. >> >> >>> Yes the resolveVariable method does allow customisation via subclassing >> > >>but the fact that the "default" source is a map is very obviously > exposed > >>> via the class API. >> >> >> Well, should we go back to the interface approach? > > > The constrast is with the StrTokenizer class. That alread has an > interface, and various implementations of the interface. Thus an > interface for this class is not inapropriate. > > I was hoping that there might have been some way to take the > StrTokenizer interface and make it top level and reuse it in all the > classes in the text package. Perhaps for locating the delimiters in > VariableFormatter. But I'm not sure that idea works. > > > Considering the current VariableFormatter class: > > a) we don't have the ability to call it directly from StrBuilder > without copying the char array to a String. (VariableFormatter needs > rewriting to operate on a char[]) Okay, to remain consistency this point sounds reasonable. If VariableFormatter is reworked to operate on a char[], StrTokenizer will certainly be useful. I think, it shouldn't be a problem to implement the Matcher interface to locate variables in the source string. But I will have to study the StrTokenizer class whether it is possible to extract the variables' names once they have been detected. > > b) we have lost the ability to have multiple substitutions I don't understand what you mean with this point. > > c) we have added a complex escaping mechanism That's true, escaping increases complexity. I think we will have to find a consense how far we want to go in this area. If you are in control over the input for VariableFormatter, escaping might not be an issue because you can choose variable delimiters that do not conflict with the output you want to generate. But if this is not the case, the use case of escaping variables will sooner or later come in naturally. > > d) we don't have a replaceOnce() method This could be realized by passing a noRecursive flag to the main substitution method; if this flag is set, no recursive calls will be made. > > I would hope that we could have a static method, that is passed all > the state, and performs all the work. That way it can be called from > StrBuilder in the most efficient way. And StrTokenizer should be > rewritten like this too. This is a good point. The main replace method could be implemented as a static method, but we would then lose the possibility of overloading the resolveVariable() method to extend the provided functionality. So in this case I would prefer to have a VariableResolver interface (instead of a plain map), which will support customization more easily. > > Stephen > Oliver --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org