Parsing a superclass object to subclass object dynamicly
I have about 20 different classes that extend a superclass. Each subclass has some methods that are not implemented in the superclass.
At runtime I need to parse the superclass object to whatever subclass object for my program to work correctly. How do I do this?
Manually I would do something like
Superclass super = method.getSomething();
Subclass sub = (Subclass)super;
This works fine, but I don't know how to do this at runtime because don't know which class that it is to be parsed. Any ideas?
thanks in advance
EDIT: I mean casting obviously.