[jdom-interest] Convert XML data to Java ojbects
Guy Nirpaz
guyn at tantian.com
Tue Sep 5 04:56:00 PDT 2000
> >
> > You need to give us more information; it's very fuzzy what you are
> > doing. I think I know, but I doubt the rest of the list does. Post your
> > configuration file (or an example), your use-case for doing this, and
> > some detail about what the result is. Then we can talk on it further.
> >
Sorry if I wasn't clear, it seems so obvious to me :-)
The mechanism can be viewed as a combination of :
JavaOutputter and ObjectBuilder (currently the names are different)
The JavaOutputter - takes a Java instance and output it to XML document -
or element
The ObjectBuilder - intantiates a Java instance out of XML element
for example -
<code>
public class Person {
private String firstName = null ;
private String lastName = null ;
private Address address = null ;
}
</code>
with getXXX methods for properties is converted by default to -
<?xml version="1.0" encoding="UTF-8"?>
<person>
<firstName>Michael</firstName>
<lastName>Jordan</lastName>
<address>
<street>Bulls court</street>
<houseNumber>100</houseNumber>
<state>IL</state>
<country>United Stated</country>
</address>
</person>
This direction eliminates the need to code conversion to XML for every
class
that can be described that way. For example - I use it to convert
EntityBeans to XML representation. By that the client application isn't
aware of the data actuall representation.
The other direction is supported as well.
The exact XML doc above can instatiate a 'live' instance of Person class.
Hope I was more clear now,
Guy
More information about the jdom-interest
mailing list