I have built up a simple GUI builder tool that I use to experiment with different layout managers and general coding exercises. Now I'm playing with a simple ( or maybe it will become not so simple) code generator that will unwrap the root container and spew out source code that can be compiled to recreate the UI structure.
Well, I guess I've gone brain dead because for the life of me, I can not recall ever explicitly testing a class to determine if its an inner class, anonymous class, component member class, etc.
With the .getClass().getName() its easy to screen out the anonymous classes with a test for the '$' delimiter, but the question becomes "Is there a more formal test that can be applied?" such as using ancestry. Would appreciate anyone's experiences in unwrapping and code generation.
If I ever get it unscrewed to the point I'm not embrassed by the code I'll post it back here for the next person's query. Thanks All, - Dan
If you use JDK 5, there are a number of new methods in the Class class which can help you - isAnonymousClass(), isMemberClass(), getContainingClass(), etc. For earlier JDKs - well, there's getDeclaringClass() at least. That can be used to tell you if you're dealing with a member class, though it's no good for identifying local or anonymous classes. What you're trying to do will be much easier under JDK 5, that's for sure.
"I'm not back." - Bill Harding, Twister
Doe, a deer, a female deer. Ray, a pockeful of sun. Me, a name, I call my tiny ad ...