first question, please be kind!
I have the following situation:
I have a couple of classes with different datas, not really complicated but not simple either.
I need to get data from these classes, from objects of these classes, and print them in a specific format, which i still don't know exactly.
For example:
public class A{
public int data1;
public String data2;
}
public class B{
public Map<String, A> map1;
}
B obj;
I need to print obj on a pdf in a predefined format, like in a table.
My idea for now is to like derive an xml description of the pdf and read the xml to guide the pdf writing regarding to where put the text and with which font.
For example:
<document>
<text id="val1.data1" x="10" y="10" />
<text id="val1.data2" x="100" y ="10" />
<text id="val2.data1" x="10" y="100" />
<text id="val2.data2" x="100" y ="100" />
</document>
This solution, even if it allows me to decouple the document format from the code, doesn't allow me to decouple retrieving the data from the object, i still need to get the ids and manually do a switch like
if(id=="data1"){
A.getData1();
}else if(id=="data2"){
A.getData2();
}
A thing i would prefer to avoid.
Any suggestion about how could i design it? i'm already able to draw on pdf anything i like in any position and retrive data when i need, i'd just like to have everything more decoupled because the document template and the data in it could change anytime as far as i know.
Thanks for any suggestion!