whew.... not quite sure if I understand the question... but it *sorta* sounds like you're looking for a local class, or an anonymous class
These are discussed a lot in the Programmer's Certification Study Forum -- do a quick search in there - I'm sure you'll find some great
thread.
Check out this one, it seems promising:
A class defined within a method