Questions tagged [xstream]

XStream is a simple Java library to serialize objects to XML and back again.

XStream

XStream is a simple library to serialize objects to XML and back again. It is typical used for Transport, Persistence, Configuration and Unit Tests.

Features

  • Ease of use. A high level facade is supplied that simplifies common use cases.

  • No mappings required. Most objects can be serialized without need for specifying mappings.

  • Performance. Speed and low memory footprint are a crucial part of the design, making it suitable for large object graphs or systems with high message throughput.

  • Clean XML. No information is duplicated that can be obtained via reflection. This results in XML that is easier to read for humans and more compact than native Java serialization.

  • Requires no modifications to objects. Serializes internal fields, including private and final. Supports non-public and inner classes. Classes are not required to have default constructor.

  • Full object graph support. Duplicate references encountered in the object-model will be maintained. Supports circular references.

  • Integrates with other XML APIs. By implementing an interface, XStream can serialize directly to/from any tree structure (not just XML).

  • Customizable conversion strategies. Strategies can be registered allowing customization of how particular types are represented as XML.

  • Error messages. When an exception occurs due to malformed XML, detailed diagnostics are provided to help isolate and fix the problem.

  • Alternative output format. The modular design allows other output formats. XStream ships currently with JSON support and morphing.

References

1024 questions
0
votes
1 answer

XML serialization using XStream

I have the following classes: class MMS { @XStreamAlias("mouse") Mouse mMouse; @XStreamAlias("less") String mLess; @XStreamAlias("ress") int mRess; } class Mouse { String name; int size; int rest; } after XStream…
dimika
  • 131
  • 2
  • 9
0
votes
1 answer

How do you annotate a java object to add an attribute to a single element using XStream?

I am trying to create a java test using XStream annotations to serialize/deserialize XML like: Hello Joe Smith 25 15
eze
  • 2,332
  • 3
  • 19
  • 30
0
votes
2 answers

Equivalent DROP_ROOT_MODE on XStream for XML conversion

I have a doubt whether it is possible to ignore the xml root element on a conversion form Object to XML with XStream, or if is there any way to replace the root element with other one, I mean: I have a function to parse custom runtime-created…
0
votes
2 answers

Is there away to configure XSream to not include values when they are equal to their default values?

I am using XStream with Annotations to go between my Java objects and XML. I am essentially trying to make the XML as minimal as possible, and one the items I want to reduce is the inclusion of boolean values when not necessary. When a boolean value…
Jacob Schoen
  • 14,034
  • 15
  • 82
  • 102
0
votes
1 answer

xStream deserialization in java

Michael Daniels 2012-10-20 2012-10-25 2012-10-11
WIllJBD
  • 6,144
  • 3
  • 34
  • 44
0
votes
1 answer

deserializing many child nodes to add references to objects xStream java

Hi I'm de serializing the following graph: I…
0
votes
3 answers

Serialization of Entity classes using Xstream

I'm using Xstream to serialize a EJB entity class to be transferred by a web service, but it also writes the database specific information in this case the following code. Is it possible to omit this information? …
0
votes
1 answer

XStream.fromXML List producing empty list

I'm trying to learn XStream, and I've followed the API as well as I can understand it, but the following code snippet List rectangleArray = new ArrayList(); xstream = new XStream(new DomDriver()); List
user1052335
0
votes
1 answer

Marshalling not working: In case of nested Dto

I am saving my configration details in an xml file its structure is somewat like this xxxxx xxxxx yyyy
Vaibhav Jain
  • 119
  • 3
  • 16
0
votes
1 answer

Need the proper object declaration for my XStream deserialization

My XML: http://api-public.netflix.com/catalog/titles/autocomplete?{-join|&|term} <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/java" class="post-tag grid--cell" title="show questions tagged 'java'" rel="tag">java</a> <a href="../../questions/tagged/xml" class="post-tag grid--cell" title="show questions tagged 'xml'" rel="tag">xml</a> <a href="../../questions/tagged/object" class="post-tag grid--cell" title="show questions tagged 'object'" rel="tag">object</a> <a href="../../questions/tagged/xstream" class="post-tag grid--cell" title="show questions tagged 'xstream'" rel="tag">xstream</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Oct 13 '12 at 23:24">asked Oct 13 '12 at 23:24</time> <a href="../../users/580548/jason" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/580548.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Jason" /> </a> <div class="s-user-card--info"> <a href="../../users/580548/jason" class="s-user-card--link">Jason</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">463</li> <li class="s-award-bling s-award-bling__gold" title="1 gold badge">1</li> <li class="s-award-bling s-award-bling__silver" title="11 silver badge">11</li> <li class="s-award-bling s-award-bling__bronze" title="25 bronze badge">25</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-12768232"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>0</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status "> <strong>1</strong> answer </div> </div> </div> <div class="summary"> <h3><a href="../../questions/12768232/package-com-thoughtworks-xstream-annotations-does-not-exist" class="question-hyperlink">package com.thoughtworks.xstream.annotations does not exist</a></h3> <div class="excerpt">I have to build a Java web project to run it locally and adjust some HTML. Unfortunately, after another updating from SVN server the project stopped being buildable. Here is the log from IntelliJ IDEA: "C:\Program Files\Java\jdk1.7.0_07\bin\java"…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/java" class="post-tag grid--cell" title="show questions tagged 'java'" rel="tag">java</a> <a href="../../questions/tagged/maven" class="post-tag grid--cell" title="show questions tagged 'maven'" rel="tag">maven</a> <a href="../../questions/tagged/intellij-idea" class="post-tag grid--cell" title="show questions tagged 'intellij-idea'" rel="tag">intellij-idea</a> <a href="../../questions/tagged/xstream" class="post-tag grid--cell" title="show questions tagged 'xstream'" rel="tag">xstream</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Oct 07 '12 at 11:03">asked Oct 07 '12 at 11:03</time> <a href="../../users/259731/noober" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/259731.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="noober" /> </a> <div class="s-user-card--info"> <a href="../../users/259731/noober" class="s-user-card--link">noober</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">4,819</li> <li class="s-award-bling s-award-bling__gold" title="12 gold badges">12</li> <li class="s-award-bling s-award-bling__silver" title="49 silver badges">49</li> <li class="s-award-bling s-award-bling__bronze" title="85 bronze badges">85</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-12702753"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>0</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>1</strong> answer </div> </div> </div> <div class="summary"> <h3><a href="../../questions/12702753/populating-list-values-using-xstream" class="question-hyperlink">Populating list values using xstream</a></h3> <div class="excerpt">I am working with Xstream to read some xml in the following format <Objects> <Object Type="System.Management.Automation.Internal.Host.InternalHost"> <Property Name="Name" Type="System.String">ConsoleHost</Property> <Property…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/java" class="post-tag grid--cell" title="show questions tagged 'java'" rel="tag">java</a> <a href="../../questions/tagged/xml" class="post-tag grid--cell" title="show questions tagged 'xml'" rel="tag">xml</a> <a href="../../questions/tagged/xml-parsing" class="post-tag grid--cell" title="show questions tagged 'xml-parsing'" rel="tag">xml-parsing</a> <a href="../../questions/tagged/xml-serialization" class="post-tag grid--cell" title="show questions tagged 'xml-serialization'" rel="tag">xml-serialization</a> <a href="../../questions/tagged/xstream" class="post-tag grid--cell" title="show questions tagged 'xstream'" rel="tag">xstream</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Oct 03 '12 at 06:11">asked Oct 03 '12 at 06:11</time> <a href="../../users/496934/user496934" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/496934.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="user496934" /> </a> <div class="s-user-card--info"> <a href="../../users/496934/user496934" class="s-user-card--link">user496934</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">3,822</li> <li class="s-award-bling s-award-bling__gold" title="10 gold badges">10</li> <li class="s-award-bling s-award-bling__silver" title="45 silver badges">45</li> <li class="s-award-bling s-award-bling__bronze" title="64 bronze badges">64</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-12669631"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>0</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>3</strong> answers </div> </div> </div> <div class="summary"> <h3><a href="../../questions/12669631/convert-java-to-xml-using-xstream" class="question-hyperlink">Convert Java to XML using xstream</a></h3> <div class="excerpt">I have started using the xstream library to convert from Java code to XML. My model java class is simple and given below: class Person { String firstname; String lastname; String age; public Person(String first, String…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/java" class="post-tag grid--cell" title="show questions tagged 'java'" rel="tag">java</a> <a href="../../questions/tagged/xml" class="post-tag grid--cell" title="show questions tagged 'xml'" rel="tag">xml</a> <a href="../../questions/tagged/xml-serialization" class="post-tag grid--cell" title="show questions tagged 'xml-serialization'" rel="tag">xml-serialization</a> <a href="../../questions/tagged/xstream" class="post-tag grid--cell" title="show questions tagged 'xstream'" rel="tag">xstream</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Oct 01 '12 at 08:15">asked Oct 01 '12 at 08:15</time> <a href="../../users/496934/user496934" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/496934.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="user496934" /> </a> <div class="s-user-card--info"> <a href="../../users/496934/user496934" class="s-user-card--link">user496934</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">3,822</li> <li class="s-award-bling s-award-bling__gold" title="10 gold badges">10</li> <li class="s-award-bling s-award-bling__silver" title="45 silver badges">45</li> <li class="s-award-bling s-award-bling__bronze" title="64 bronze badges">64</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-12634577"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>0</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>3</strong> answers </div> </div> </div> <div class="summary"> <h3><a href="../../questions/12634577/conversion-of-java-object-into-xml-and-parse-it-using-dom-sax" class="question-hyperlink">Conversion of Java object into XML and parse it using DOM/SAX</a></h3> <div class="excerpt">I need to convert Java object into XML object and send it across to client browser from server. And in client browser, i need to parse the obtained XML object using DOM/SAX or anything that suits and display it in UI. Which one suits the above?…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/xml" class="post-tag grid--cell" title="show questions tagged 'xml'" rel="tag">xml</a> <a href="../../questions/tagged/json" class="post-tag grid--cell" title="show questions tagged 'json'" rel="tag">json</a> <a href="../../questions/tagged/jaxb" class="post-tag grid--cell" title="show questions tagged 'jaxb'" rel="tag">jaxb</a> <a href="../../questions/tagged/marshalling" class="post-tag grid--cell" title="show questions tagged 'marshalling'" rel="tag">marshalling</a> <a href="../../questions/tagged/xstream" class="post-tag grid--cell" title="show questions tagged 'xstream'" rel="tag">xstream</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Sep 28 '12 at 06:15">asked Sep 28 '12 at 06:15</time> <a href="../../users/149535/viswa" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/149535.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Viswa" /> </a> <div class="s-user-card--info"> <a href="../../users/149535/viswa" class="s-user-card--link">Viswa</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">1,357</li> <li class="s-award-bling s-award-bling__gold" title="3 gold badges">3</li> <li class="s-award-bling s-award-bling__silver" title="18 silver badges">18</li> <li class="s-award-bling s-award-bling__bronze" title="30 bronze badges">30</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-12586114"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>0</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status "> <strong>1</strong> answer </div> </div> </div> <div class="summary"> <h3><a href="../../questions/12586114/how-can-i-make-pre-configured-templates-using-xstream" class="question-hyperlink">How can I make pre-configured templates using XStream</a></h3> <div class="excerpt">I am currently developing a system that uses XStream to create objects from XML. An example object would be @XStreamAlias("TestClass") public class TestClass{ @XStreamAlias("format") private String format; public String getFormat(){ return…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/java" class="post-tag grid--cell" title="show questions tagged 'java'" rel="tag">java</a> <a href="../../questions/tagged/xml" class="post-tag grid--cell" title="show questions tagged 'xml'" rel="tag">xml</a> <a href="../../questions/tagged/xstream" class="post-tag grid--cell" title="show questions tagged 'xstream'" rel="tag">xstream</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Sep 25 '12 at 15:23">asked Sep 25 '12 at 15:23</time> <a href="../../users/1514047/stijnvdk" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/1514047.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Stijnvdk" /> </a> <div class="s-user-card--info"> <a href="../../users/1514047/stijnvdk" class="s-user-card--link">Stijnvdk</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">556</li> <li class="s-award-bling s-award-bling__gold" title="4 gold badges">4</li> <li class="s-award-bling s-award-bling__silver" title="7 silver badges">7</li> <li class="s-award-bling s-award-bling__bronze" title="20 bronze badges">20</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="s-pagination pager fr"> <a class="s-pagination--item" href="../../questions/tagged/xstream_page=64" rel="prev" title="Go to page 64">Prev </a> <a class="s-pagination--item" href="../../questions/tagged/xstream_page=1" rel="" title="Go to page 1">1</a> <a class="s-pagination--item" href="../../questions/tagged/xstream_page=2" rel="" title="Go to page 2">2</a> <a class="s-pagination--item" href="../../questions/tagged/xstream_page=3" rel="" title="Go to page 3">3</a> <div class="s-pagination--item s-pagination--item__clear">…</div> <a class="s-pagination--item" href="../../questions/tagged/xstream_page=68" rel="" title="Go to page 68">68</a> <a class="s-pagination--item" href="../../questions/tagged/xstream_page=69" rel="" title="Go to page 69">69</a> <a class="s-pagination--item" href="../../questions/tagged/xstream_page=66" rel="next" title="Go to page 66"> Next</a> </div> </div> </div> </div> </div> <script src="../../static/js/stack-icons.js"></script> <script src="../../static/js/fromnow.js"></script> </body> </html>