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

Premature end of file. exception trying to parse xml from Zipinputstream

I am trying to extract an xml file & other contents from a ZipInputStream and create my objects from xml parsing the zipinputstream. However I am getting Premature end of file exception - for the following code or Stream Closed - when I dont have…
0
votes
3 answers

Is there any tool or library that converts YAML or XML files into Java code?

Is there a tool or library that converts object serialized into YAML or XML file into Java code creating that object? From technical point of view, I see no difficulties here. Both Yaml and XStream (or other similar tools) needs to find Java class…
Danubian Sailor
  • 1
  • 38
  • 145
  • 223
0
votes
1 answer

xStream doesn't work correct with list and attributes

I'm trying to make some objects of a XML file. But i'm doing something wrong, this is the method where I put in the xml file: XStream x = new XStream(); XML v = (XML) x.fromXML("World…
Danny Gloudemans
  • 2,597
  • 7
  • 39
  • 57
0
votes
2 answers

Java XStream CannotResolveClassException

I am trying to parse an XML file to objects using XStream but I am getting this exception: Exception in thread "main" com.thoughtworks.xstream.mapper.CannotResolveClassException: servers at …
Jean-François Beaulieu
  • 4,305
  • 22
  • 74
  • 107
0
votes
1 answer

XStream ConversionException the second time I parse an XML file

I'm trying to read a TreeMap from an XML file using XStream (I previously created the XML file using XStream too) in my Android application. I simply do this in a static method of a class File f = new File(Environment.getExternalStorageDirectory(),…
luthier
  • 2,674
  • 4
  • 32
  • 35
0
votes
1 answer

Remove/Replace/Combine tag generated from parent List<> object in XStream

I'm using XStream to convert java objects to their XML counterparts. One such object contains a List windows variable, which when generated displays: Monthly
JWiley
  • 3,129
  • 8
  • 41
  • 66
0
votes
1 answer

Steps in XSTREAM

I want to read an XML file into Java objects. Can XStream do this? I do not have a XML-Schema for my file. Can anyone suggest me any alternatives ?
user892871
  • 1,025
  • 3
  • 13
  • 28
0
votes
1 answer

Why am I getting conversion exception in this code for xstream?

I've the following test code which is not working. XStream xStream = new XStream(new DomDriver()); xStream.alias(clazz.getName(), clazz); String…
gizgok
  • 7,303
  • 21
  • 79
  • 124
0
votes
1 answer

xstream primitive deserialization doesn't work?

I'm using XStream serializer to serialize a primitive and faced problem with deserializing it. Here is the problem description: Say, I have: int i = 80; I serialize it as following: serializer.toXML(i, new FileOutputStream("me.xml")); and…
mr.nothing
  • 5,141
  • 10
  • 53
  • 77
0
votes
1 answer

How to deserialize xml using XStream in spring mvc

Im receiving this

001

002

my dispatcher looks like this
edlizano
  • 15
  • 6
0
votes
3 answers

Java constructor with method that creates instance of that object

I want to create constructor which takes xml as string and all variables would be fill from that. That xml is created by XStream so I think that something like this would work but don´t know what to add to left side: public xmlpacket(String…
Libor Zapletal
  • 13,752
  • 20
  • 95
  • 182
0
votes
2 answers

Serializing to XML using XStream but not getting all fields

I have a class called Lookup that has two properties: public class Lookup { private String surveyName; private String GUID; public Lookup(String name, String guid){ this.surveyName = name; this.GUID = guid; …
Ayush
  • 41,754
  • 51
  • 164
  • 239
0
votes
2 answers

Xstream: How to deserialize Xml with array

I've an xml with a repeating array element, how do I deserialize it? afa asgfasg hkjvlk sdsdgsdg ... XStream xstream = new…
Taranfx
  • 10,361
  • 17
  • 77
  • 95
0
votes
1 answer

Parsing mixed text and xml nodes with Xstream

I'm trying to parse xml done like this: auieo I'm using Xstream, and I tried to write a specific Converter, but it does not work :( I don't understand how to split the…
Diegolo
  • 289
  • 1
  • 4
  • 11
0
votes
1 answer

xstream, how to serialize a list to xml

I am using xstream and trying to serialize a List to XML. I need an output structure like The object to serialize would be something like an …