wrote:
> Ross Bamford wrote:
> > Hi all,
> >
> > Does anyone know of a way to do instanceof checks from VTL? At the
> > moment I'm providing a simple isA method on objects, but I am thinking
> > there must be another way...
>
> You can use a tool... maybe
Ross Bamford wrote:
Hi all,
Does anyone know of a way to do instanceof checks from VTL? At the
moment I'm providing a simple isA method on objects, but I am thinking
there must be another way...
You can use a tool... maybe the tool can take advantage of the
velocity internal introspector
Hi Ross,
> Does anyone know of a way to do instanceof checks from VTL? At the
> moment I'm providing a simple isA method on objects, but I am thinking
> there must be another way...
>
> The isA method works, but (at the moment) only checks the actual
> classname (not sup
Hi all,
Does anyone know of a way to do instanceof checks from VTL? At the
moment I'm providing a simple isA method on objects, but I am thinking
there must be another way...
The isA method works, but (at the moment) only checks the actual
classname (not superclasses). Before I go about wo
That's no excuse to resort to 'instanceof'. there are "other way" to
"tell" if something is a box or circle.
$foo.isCircle()
$foo.isSquare()
(well... maybe not...)
#set ($myshape = $foo.getMyShape())
#if ("circle"==$myshape)
#elseif ("square&q
> -Original Message-
> From: J. B. Rainsberger [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, March 09, 2004 2:45 PM
> To: Velocity Users List
> Subject: Polymorphism (was Re: 'instanceof')
>
> Why not just invoke draw() on the Shape and let /it/ figure
>
[EMAIL PROTECTED] wrote:
Somewhere you want to use an instanceof check. In general, a
performs an instanceof check in an 'if' statement of some kind.
So apply Replace Conditional with Polymorphism [Refactoring],
which generally introduces a Strategy [GoF:Design Patterns] into
the
I feel like donating more code, so here goes:
public boolean instanceOf(Class c, Class n)
{
return n.isAssignableFrom(c);
}
public boolean instanceOf(Object o, String className)
{
try {
return instanceOf(o.getClass(), Class.forName(className));
} catch (ClassNotFoundException