XStream – Basic Built-in Converters

In the previous tutorials we saw an example of how to convert java object to XML and back. That tutorial also explained the concept of aliases and implicit collection.In the last tutorial we show how to write a custom converter. In this tutorial, lets see some of the basic built in converters of XStream and how the resultant XML from those converters look like. We will look at how the following types are converted. XStream has converters for each of these. These are just a sample of the converters that XStream has. These converters only exist for a better and faster handling of a type compared to the generic converters.

  • BigDecimal
  • BigInteger
  • boolean
  • byte
  • char
  • Date
  • Double
  • Float
  • int
  • Long
  • Object
  • StringBuffer
  • StringBuilder
  • URI
  • URL
  • UUID

In the next tutorial we look at examples of arrays and Collections.

The toXML method prints this

The fromXML method prints this

Leave a Reply

Your email address will not be published. Required fields are marked *