• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Java to XML serialisation principles

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All.

I`m struggling to understand how to serialise and deserialise Java complex objects to and from XML.

For example , if i have next class




How it should be serialised\deserialized to XML ,considering that patternsSet is a complex type with contents of regexp Pattern objects?
Should xml related to 1 instance have another XML file where pattersSet contents is described separately ?
What are the best practices to create XML configs, that will be converted to Objects ,where one field keeps some Collection with some complex structures inside it ?

Many thanks for any help !
 
Marshal
Posts: 76462
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I presume Pattern is serialisable?

Can you make that into a Java Bean and use the normal beans strategies? You do not normally serialise anything to XML but to a byte[] or similar, so beans is a more likely path to XML.

Moving discussion as too difficult for this forum.
 
Saloon Keeper
Posts: 14321
321
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have a look at JAXB.
 
Daniel Gurianov
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Place where i stuck at this moment is , that when i do marshall to XML , im getting this strange Pattern lines instead of unmarshalled pattern to the String form, i would expect.



I`m missing something in my understanding here .
The Object i`m trying to marshal to xml is next (shortened version) :


I would expect marshaller to look inside pattern objects ad use toString to reperesent value in XML.
 
Who among you feels worthy enough to be my best friend? Test 1 is to read this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic