[semi-OT] java objects persistence and XML id/idref

R

rico

Hello All.
I need some pointers as to how I go about XML'izing a java object
and referencing it later on if it is encountered in another object in the
XML'ization process.
I believe I have to use id & idref... I am thinking the object would
have to be 'marked' in some way that it has already been serialized
and what's the corresponding id...
Some pointers on this topic would be greatly appreciated.
Thanks.

Rico.
 
J

John C. Bollinger

rico said:
I need some pointers as to how I go about XML'izing a java object
and referencing it later on if it is encountered in another object in the
XML'ization process.
I believe I have to use id & idref... I am thinking the object would
have to be 'marked' in some way that it has already been serialized
and what's the corresponding id...
Some pointers on this topic would be greatly appreciated.

How about a map from objects to IDs? That seems pretty straightforward.
If the map doesn't contain a mapping for a particular object then it
hasn't been serialized yet; if it does then you have the appropriate
value for an IDREF. The only hitch is generating appropriate unique
IDs in the first place, but that is certainly doable. You could use the
objects' hashCodes in such a scheme, but beware that hashCodes are not
unique.


John Bollinger
(e-mail address removed)
 
R

Rico

How about a map from objects to IDs? That seems pretty straightforward.
If the map doesn't contain a mapping for a particular object then it
hasn't been serialized yet; if it does then you have the appropriate
value for an IDREF. The only hitch is generating appropriate unique
IDs in the first place, but that is certainly doable. You could use
the objects' hashCodes in such a scheme, but beware that hashCodes are
not unique.

Thanks a lot John. Looks straightforward indeed.

Rico.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top