Skip to end of metadata
Go to start of metadata

GumTree provides an useful API to handling parameters or properties in XML format. Assume you want to configure your system using key-value pairs, and make them serialisable, XStream + org.gumtree.core.util.IParameters is your answer.

To use this API, you need to import from the org.gumtree.core bundle:

To serialise or deserialise using XStream, we need to configure it to support customised converter:

Example 1 - String properties

Say we have three key value paris as shown:

Key

Value

title

Big Title

visible

false

count

3

Equivalent XML using the parameters API will be:

In the Java API, you can retrieve the content by:

Example 2 - Object properties

Notice in example 1 all properties are stored in String. This is true that by default all properties are String in XML format. However, the parameters API can store any arbitrary object as value:

Retrieving the content is simple:

Labels: