J
Jason Cavett
I'm creating a system to parse various different files. Each file has
a certain format, so I have different parsers to handle each format
which is determined at runtime. Each parser is a subclass of
"FileParser." Additionally, each parser has a single constructor that
accepts three pieces of information (all the same information).
I am also creating an XML config file that holds information on the
parsers that are important to the application (as some applications
want certain parsers and others want other types of parsers - this
makes it simple to switch out the config file and so the correct
parsers are used).
What I'm wondering is, how do I instantiate these classes via Java
reflection? Normally when I use Java reflection, I have a default (no
arg) constructor. In this case, I have to pass in some information
before I can instantiate. Is this even possible?
I've searched for code examples online, but I can't find the
information I'm looking for. Any help would be much appreciated.
a certain format, so I have different parsers to handle each format
which is determined at runtime. Each parser is a subclass of
"FileParser." Additionally, each parser has a single constructor that
accepts three pieces of information (all the same information).
I am also creating an XML config file that holds information on the
parsers that are important to the application (as some applications
want certain parsers and others want other types of parsers - this
makes it simple to switch out the config file and so the correct
parsers are used).
What I'm wondering is, how do I instantiate these classes via Java
reflection? Normally when I use Java reflection, I have a default (no
arg) constructor. In this case, I have to pass in some information
before I can instantiate. Is this even possible?
I've searched for code examples online, but I can't find the
information I'm looking for. Any help would be much appreciated.