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 cnfe) {}
    return false;
}       

This code is more "correct" than what I posted previously.
The prior code had variable performance, and could be faster
or slower, depending on how many comparisons were required
to find a match.  This code has a fixed execution time,
which is almost completely dependent on Class.forName().


Geir Magnusson Jr wrote: [SNIP]

Why is


#if($tool.instanceOf($foo, "java.lang.String") == true )

so bad?


Works for me.


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



Reply via email to