Reflection & DOM Approach:
The strength of any tool is the simplicity of its approach. Our executive Reflection DOM
Approach - Executive Summary diagram shows the goal of our conversion of a bean (dataobject)
into the XML Report. The following are Java data fields:
public class MyDataObject
{
|
private String
|
firstName
|
= Constants.NO_VALUE_IN_STRING;
|
|
private String
|
lastName
|
= Constants.NO_VALUE_IN_STRING;
|
|
private long
|
ssNumber
|
= Constants.NO_VALUE;
|
|
private Set<AddressDataObject>
|
addressDataObject_SET_Handle
|
= new HashSet<AddressDataObject>(0);
|
|
private Set<EmploymentHistoryDataObject>
|
employmentHistoryDataObject_SET_Handle
|
= new HashSet<EmploymentHistoryDataObject>(0);
|
|
private Set<CreditCardsDataObject>
|
creditCardsDataObject_SET_Handle
|
= new HashSet<CreditCardsDataObject>(0);
|
...
}
We basically converted the fields including the Sets of other beans (Address, Employment
History and Credit Cards) into a sub-tag with nesting beans - classes:
DATA_OBJECT
DATA_OBJECT_SET
DATA_OBJECT_N
To show the details of how our approach is done in Java using both Reflection
and DOM, we need to present the actual Java code. Our one-to-one conversion from
MyFirstBean Class to MyFirstBeanXMLFileConversion.xml in the Data Objects section
is a good example of how we did the conversion.
The code is actually is very simple and straight forward.
The following link open the Java code for Constants.java, MyFirstBean.java, MyFirstBeanDOM_XML_Converter.java:
Constants.java
MyFirstBean.java
MyFirstBeanDOM_XML_Converter.java
Readers my request the code for the more complex beans conversion by emailing a request to: