J
Josef Garvi
I have a file that may contain different types of data.
Depending on the contents of the file, I would like to create different
types of objects. Is there a way that I can let my file parsing class know
what processing classes are available, so that it can create an instance of
the appropriate class?
I would prefer not having to couple my file parser class to the processing
classes, so that I could add new processing classes for other data types
without having to modify the code of the file parser in any way. How can I
solve this? Is there for example a way of finding all classes in a package,
so I can load them and have them register themselves with the file parser
in their static initialisers?
Or am I forced to hard-code the names of all processing classes in my file
parser class?
--
Josef Garvi
"Reversing desertification through drought tolerant trees"
http://www.eden-foundation.org/
new income - better environment - more food - less poverty
Depending on the contents of the file, I would like to create different
types of objects. Is there a way that I can let my file parsing class know
what processing classes are available, so that it can create an instance of
the appropriate class?
I would prefer not having to couple my file parser class to the processing
classes, so that I could add new processing classes for other data types
without having to modify the code of the file parser in any way. How can I
solve this? Is there for example a way of finding all classes in a package,
so I can load them and have them register themselves with the file parser
in their static initialisers?
Or am I forced to hard-code the names of all processing classes in my file
parser class?
--
Josef Garvi
"Reversing desertification through drought tolerant trees"
http://www.eden-foundation.org/
new income - better environment - more food - less poverty