|Date Added:||7 November 2009|
|File Size:||28.81 Mb|
|Operating Systems:||Windows NT/2000/XP/2003/2003/7/8/10 MacOS 10/X|
|Price:||Free* [*Free Regsitration Required]|
Now that we have configured a simple class to play with, let’s see what XStream converters can do for us Jeromy Evans 4 6.
The public class Hello imports only one class, com. XStream’s primary purpose is for serialization.
This is a very quick introduction to XStream. Post as a guest Name. It is available in the sample archive for this article. This article has introduced you to the basic features and capabilities of XStream.
The alias method creates an alias XML element name for the Date class, changing the default name from Date to date. You work on a stream and accessing the value of a tag or its members will close the surrounding tag that is still active when the method is called. Joe Walnes explained the following in private correspondence: The line creates a new object newdate using the fromXML method to convert the string xml back to an object also casting it as Date.
Serializing Java Objects with XStream
Using Another Class The next program, Instant. How does one do this?
Note, that in implementation jafa a SingleValueConverter is required for attributes, since these objects have to be represented by a single string only. We convert no derived classes this time, since they might have additional fields.
You could not add the UTF-8 header this way however XStream uses the fully qualified class name for the element name, including the package name, so the alias method will come in handy for tweaking names. Or look into the condensed overview how to configure XStream to tweak the output.
XStream is being actively developed by a small project team with over a dozen contributors. The canConvert method is plain simple. With a current version of XStream, Jeromy’s example would look like this: Now that we know how the Converter interface works, let’s create a simple calendar converter which uses the locale to convert the information.
The current, stable version of XStream is 1. This is particularly useful as a form of persistence no complicated database mappings required or for sending objects over the wire. By clicking “Post Your Answer”, you acknowledge that you have read our updated terms of servicejzva policy and domdeiver policyand that your continued use of the website is subject to these policies.