commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Rall <>
Subject Re: StringUtils constructor is private
Date Mon, 12 Aug 2002 21:38:04 GMT
"Stephen Colebourne" <> writes:

> From: "Daniel Rall" <>
> > "Stephen Colebourne" <> writes:
> > > But given Velocity is broken, I suppose we have to do something. Either
> a
> > > public constructor or a public static final instance variable 'INSTANCE'
> > > would do. But I hate the very thought of it. And it affects all of
> > > [collections], [pattern and [lang].
> >
> > Velocity is not broken -- it simply requires a class instance to
> > reference methods of that class.  Valid in Java, valid in Velocity.
> But Velocity shouldn't require the class instance. Reflection doesn't.
> Something like:
>  context.putStatic("foo", StringUtils.class);
>  #set ($bar = $foo.chomp())

In your example, there is no way to know whether you want to invoke
methods of the Class instance you added to the context, or methods of
the class which it represents.

That's why I suggested the following wrapper (which may even exist,
for all I know):

What would be really convenient is a class with hooks into the
Velocity internals which takes a Class object in its constructor and
invokes methods via reflection (much as Velocity does anyhow), using
Velocity's internal introspection and/or uberspection caches.

Daniel Rall <>

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message