|Convert a STRING!!!! to a CLASS!!! I hear you scream. Pull up a pew and let me explain the problem I have.
I am creating an application that pulls various values from an XML file and then uses these values to create various pieces of text within a PDF document. Now using iTextSharp (http://itextsharp.sourceforge.net/index.html[^]) this is fairly easy.
The problem is that I want/need everything to be driven by XML parameters, as an example to set the font of a particular piece of text you would use the following code :
basefont = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED)
CreateFont takes 3 parameters, and I want to be able to specify these parameters in the XML.
When the data comes out of the XML file it is in string format. So the desired effect can easily (ish) be achived, by using a massive multiple if/switch statement.
The problem is that using if's everything is hardcoded, so if I decided to use an uncoded font I would have to recompile and re-release code, which is a pain.
What I would like to do is set the follow parameters in XML :
Then use these as class values, rather than have to mess around with if's and switch's, so if I pulled the values using their XML tag names I would have the following line of code
basefont = BaseFont.createFont(basefont_string, basefont_encoding, basefont_embedding)
Did that make sense?
post.mode = signature;
SELECT everything FROM everywhere WHERE something = something_else;
> 1 Row Returned