Re: instanceof

2005-04-11 Thread Ross Bamford
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

Re: instanceof

2005-04-11 Thread Christoph Reck
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

Re: instanceof

2005-04-11 Thread Shinobu Kawai
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

instanceof

2005-04-11 Thread Ross Bamford
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

RE: Polymorphism (was Re: 'instanceof')

2004-03-09 Thread Mike Curwen
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

RE: Polymorphism (was Re: 'instanceof')

2004-03-09 Thread MNewcomb
> -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 >

Polymorphism (was Re: 'instanceof')

2004-03-09 Thread J. B. Rainsberger
[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

Re: [PATCH] instanceof

2004-03-09 Thread Nathan Green
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