Hello,

Since Interpolation is so close in intent to MessageFormat, I seems less
confusing to Java (as opposed to Perl) people to use a
MessageFormat-like name. For example MappedMessageFormat is not bad.

Look at java.text.MessageFormat [1], Interpolation seems to do the same
kind of thing. For example [1], with MessageFormat, you can:

Object[] arguments = {
     new Integer(7),
     new Date(System.currentTimeMillis()),
     "a disturbance in the Force"
 };

 String result = MessageFormat.format(
     "At {1,time} on {1,date}, there was {2} on planet
{0,number,integer}.",
     arguments);

 output: At 12:30 PM on Jul 3, 2053, there was a disturbance
           in the Force on planet 7.

The new Interpolation version would be:

   Map arguments = HashMap();
   valuesMap.put( "time", new Date(System.currentTimeMillis()) );
   valuesMap.put( "what", "a disturbance in the Force" );
   //etc
   String result = Interpolation.interpolate(
     "At ${time} on ${date}, there was ${what} on planet ${planet}.",
     arguments);

So the added value to MessageFormat is a more flexible way to pass in
arguments (no positional issues). So why call it something oh-so
completely different from MessageFormat which is so close in
functionality? ;-)

The MappedMessageFormat would also have a "format" method, not an
"interpolate".

Thanks,
Gary

[1] http://java.sun.com/j2se/1.3/docs/api/java/text/MessageFormat.html

> -----Original Message-----
> From: Gary Gregory [mailto:[EMAIL PROTECTED]
> Sent: Friday, August 27, 2004 09:35
> To: Jakarta Commons Developers List
> Subject: RE: [lang] Interpolation
> 
> I do not like a *Utils name for this because I'd like the class to be
> instantiable per my example.
> 
> Gary
> 
> > -----Original Message-----
> > From: Stephen Colebourne [mailto:[EMAIL PROTECTED]
> > Sent: Thursday, August 26, 2004 17:35
> > To: Jakarta Commons Developers List
> > Subject: Re: [lang] Interpolation
> >
> > 1) I felt the 'interpolateRepeatedly' scanned badly as a method
name.
> But
> > I
> > couldn't think of anything better.
> >
> > 2) I wondered if it should be InterpolateUtils, or some such to fit
> with
> > our
> > Utils classes.
> >
> > Stephen
> >
> > ----- Original Message -----
> > From: "Gary Gregory" <[EMAIL PROTECTED]>
> > To: "Jakarta Commons Developers List"
<[EMAIL PROTECTED]>
> > Sent: Thursday, August 26, 2004 11:52 PM
> > Subject: RE: [lang] Interpolation
> >
> >
> > > > (3) Usage.
> > > >
> > > > I'd like that class to be more flexible in order to do the
> following
> > for
> > > > example:
> > > >
> > > > Interpolation interpolation = new Interpolation();
> > > > interpolation.setStartMarker("<");
> > > > interpolation.setEndMarker(">");
> > > > interpolation.setMap(aMap);
> > > > String news = interpolation.interpolate(templateString);
> > >
> > > Sounds interesting.  ${..} seems a common default though.
> > >
> > > Hen
> >
> > Agreed, the defaults are fine. The pieces should be pluggable is all
I
> > am saying which gives us the biggest bang for the buck with this new
> > class.
> >
> > Gary
> >


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

Reply via email to