[jdom-interest] Converting Java Objects to XML

Jeff Martin jeff at reportmill.com
Fri Oct 11 15:05:49 PDT 2002


Well the Caster guys are doing the whole Object-Relational mapping 
thing, which is a much more ambitious project. However, in my research 
over the last few weeks I couldn't find a standard convention or 
library for writing out an object representation for an object graph 
(the JSX library came the closest, but it writes out only "settable" 
attributes - and blew my data up by an order of magnitude). I was 
surprised, because this seems crucial to using XML as an interchange 
format, rather than a persistence format (where the consumer could 
count on having the archived classes available).

My class provides a convention and implementation of writing out an 
object graph in a concise, but fully descriptive way (including 
circular references, value typing, etc.). The RMSchema element is a 
simple list of Entities (with their properties). I have an RMXMLReader 
class that easily reads this file and constructs a simple hierarchy of 
Maps/Lists/Strings/Numbers/Dates, but right now it depends on a bit of 
code from the rest of my project. It will take about a day to make it 
stand-alone, like RMXMLWriter. I'll have to see if there's any interest 
in this before I spend the time.

Re: Your last question about a public method which calls a private 
method: this isn't an obstacle - my class uses basic Java Reflection - 
if they chain a call like that, it has no bearning. My object sees only 
the result from the top-level public method, and represents that 
member/value.

jeff

On Friday, October 11, 2002, at 04:47  PM, Frank Sauer wrote:

> You call that less grand???
> How do you plan on representing the public behavior in a way
> that it can be reconstructed in a runnable fashion? What if
> a public methods calls a private method that's not included?
>
> Frank
>
> -----Original Message-----
> From: Jeff Martin [mailto:jeff at reportmill.com]
> Sent: Friday, October 11, 2002 4:27 PM
> To: Grinvald, Edward
> Cc: jdom-interest at jdom.org
> Subject: Re: [jdom-interest] Converting Java Objects to XML
>
>
> Well my goal is much less grand and slightly different. This class
> doesn't create an "archive" of an object graph, it creates a
> "representation" - which includes all public methods (including any
> derived business logic methods), not just values from getter/setter
> methods. This is great for importing a description of an object graph
> into an application that doesn't have access to the original classes.
>
> Also, it's a single class file - no setup and configuration necessary.
> It just turns objects to XML in fell swoop.
>
> jeff




More information about the jdom-interest mailing list