aspose file tools
The moose likes Java in General and the fly likes Explicit tests for inner, member, and anonymous classes Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Explicit tests for inner, member, and anonymous classes" Watch "Explicit tests for inner, member, and anonymous classes" New topic
Author

Explicit tests for inner, member, and anonymous classes

Daniel Puryear
Greenhorn

Joined: Jun 02, 2002
Posts: 22
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
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18670
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Explicit tests for inner, member, and anonymous classes
 
Similar Threads
What is a static class???Kindly let me know.
accessibility modifiers for classes
When is an anonymous inner class NOT an inner class? Always?
How many object is eligible for garbage collection?
Inner class doubt