You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Peter Norsker <pe...@norsker.com> on 2002/05/08 23:15:12 UTC

Any need for a Java xml serializer/deserializer??

Hi all

I've been developing an extendable Java xml serializer/deserializer for a
while, and would like to contribute it to the Commons subproject if there is
any interest.

Two simple classes must be subclassed for implementing a serializer and a
deserializer. A set of default serializers and deserializers are included:

- all primitives and theire wrappers
- java.lang.String
- java.lang.Class
- java.lang.StringBuffer
- java.util.Date
- java.util.List
- java.util.Map
- java.util.Set
- arrays of primitives or objects
- any bean structure (excluding transient fields)

All crossreferences in the objectstructure is maintained from the serialized
object to the deserialized object.
The way it workes are as follows:

Serializing:
An objects is turned into a metarepresentation of the serialized object and
then to xml.

Deserializing:
The xml is turned into the metarepresentation of the serialized object and
then to the object.


This is a short example of a serialized java.util.HashMap:

<?xml version="1.0" encoding="UTF-8" ?>
<data time="1020892365621">
	<object id="0" type="dk.pvk.util.xml.TestB">
		<property name="map">
			<object id="1" type="java.util.HashMap">
				<mapping>
					<key>
						<object id="2" type="java.lang.String" value="element2" />
					</key>
					<value>
						<object id="3" type="java.lang.StringBuffer">
							Hello+world
						</object>
					</value>
				</mapping>
				<mapping>
					<key>
						<object id="4" type="java.lang.String" value="element1" />
					</key>
					<value>
						<object id="5" type="java.lang.Integer" value="5" />
					</value>
				</mapping>
			</object>
		</property>
	</object>
</data>

This is a very breif description of the functionality but it has any
interest please say so.

Regards
Peter Norsker


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Any need for a Java xml serializer/deserializer??

Posted by Stephen Colebourne <sc...@eurobell.co.uk>.
Peter,
The interesting thing about Object to XML conversion and vice versa seems to
be how many different people are working on different solutions. Here are
some of those I know about (OSS):
commons digester
commons sandbox betwixt
xo (somebody may correct me, but I think thats an apache xml to object
convertor)
castor (www.castor.org)
jox (www.jox.sourceforge.net)
joda (www.joda.org) (my own)
Sun's JavaBean long term persistence in 1.4

In addition to this there are all the Java DOM solutions, plus all the JAXB
style object/xml binding solutions. In fact I have visited various other
websites where XML is not their main goal, but they have felt the need to
develop Object to XML code (for example www.dautelle.com/jade/ which is a
units implementation and shouldn't be interested in XML).

I guess that this kindof shows just how big a problem people are finding
this to be, and how one single solution is not winning out. What I mean by
this is that most people choosing a unit test tool will use JUnit. Most
people wanting a build tool will use Ant. And so on.

Either Objects to XML has not yet reached maturity. Or there are genuinely
many ways to achieve the same goal. My judgement is that there are
definitely many ways, but I'm not sure that they are genuinely different.
BTW, I wrote my own because I could find nothing that did the job I needed .

Of course none of that answers your question - but thats really one for the
committers. I guess I'm just saying that some similar stuff already exists
in the commons, and elsewhere.

Stephen

----- Original Message -----
From: Peter Norsker <pe...@norsker.com>
To: <co...@jakarta.apache.org>
Sent: Wednesday, May 08, 2002 10:15 PM
Subject: Any need for a Java xml serializer/deserializer??


> Hi all
>
> I've been developing an extendable Java xml serializer/deserializer for a
> while, and would like to contribute it to the Commons subproject if there
is
> any interest.
>
> Two simple classes must be subclassed for implementing a serializer and a
> deserializer. A set of default serializers and deserializers are included:
>
> - all primitives and theire wrappers
> - java.lang.String
> - java.lang.Class
> - java.lang.StringBuffer
> - java.util.Date
> - java.util.List
> - java.util.Map
> - java.util.Set
> - arrays of primitives or objects
> - any bean structure (excluding transient fields)
>
> All crossreferences in the objectstructure is maintained from the
serialized
> object to the deserialized object.
> The way it workes are as follows:
>
> Serializing:
> An objects is turned into a metarepresentation of the serialized object
and
> then to xml.
>
> Deserializing:
> The xml is turned into the metarepresentation of the serialized object and
> then to the object.
>
>
> This is a short example of a serialized java.util.HashMap:
>
> <?xml version="1.0" encoding="UTF-8" ?>
> <data time="1020892365621">
> <object id="0" type="dk.pvk.util.xml.TestB">
> <property name="map">
> <object id="1" type="java.util.HashMap">
> <mapping>
> <key>
> <object id="2" type="java.lang.String" value="element2" />
> </key>
> <value>
> <object id="3" type="java.lang.StringBuffer">
> Hello+world
> </object>
> </value>
> </mapping>
> <mapping>
> <key>
> <object id="4" type="java.lang.String" value="element1" />
> </key>
> <value>
> <object id="5" type="java.lang.Integer" value="5" />
> </value>
> </mapping>
> </object>
> </property>
> </object>
> </data>
>
> This is a very breif description of the functionality but it has any
> interest please say so.
>
> Regards
> Peter Norsker
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>