Moose 0.4.1 #1208 Released

Release Information:

The 0.4.1 release of Moose includes support for new "inline" style lists. There are now two different representation choices when creating mappings that use lists.

Here is an example mapping domain class:

@XML(name="list-example")
public class ListExample {
	// Getters and Setters omitted for brevity
	
	@XMLList(name="tags", elementName="tag")
	private List<String> tags;
}

Instances of ListExample marshall into XML like the following:

<list-example>
	<tags>
		<tag>Tag 1</tag>
		<tag>Tag 2</tag>
	</tags>
</list-example>

That's fine for many scenarios. I was working on an application where I needed to read and write GPX data. GPX data contains "list" data represented alongside other field data, like this:

<trk>
	<name>An Example Track</name>
	<trkseg/>
	<trkseg/>
</trk>

When developing my mapping domain, I wanted this XML to end up in a bean like the following:

public class Track {
	// Getters and Setters omitted for brevity

	private String name;
	private List<TrackSegment> trackSegments;
}

This scenario wouldn't work with Moose 0.4.0. The 0.4.0 version would have insisted that the trkseg list elements be contained within some higher level element that only occurred once.

Moose 0.4.1 now supports the old idiom, where the higher level parent element is present for lists (we refer to this as a "rooted" list), as well as a new idiom where list elements do not need a container element (we refer to this as an "inline" list).

With 0.4.1, I can annotate my mapping domain class like this to handle the scenario:

@XML(name="trk")
public class Track {
	// Getters and Setters omitted for brevity

	@XMLField(name="name")
	private String name;
	
	@XMLList(name="trkseg", style=XMLListStyle.INLINE)
	private List<TrackSegment> trackSegments;
}

Not rocket science, but now there's a little more flexibility in how mappings can be defined. The developer guide has been updated with information on how to use the new inline list style.

The 0.4.1 series will include a few additional patch releases. I expect to support similar configurability for Map types. The SchemaGenerator is getting a light round of improvements to ensure that all cardinalities are represented correctly. Also keep an eye out for additional documentation improvements.

Source Distribution:

The source distribution includes all of the source code for the framework, the entire suite of unit tests, the examples and all of the required dependencies. Also includes a pre-built binary library jar.

quigley-moose-0.4.1.1208.zip

QUIGLEY.COM — © Copyright 2008-2010 Michael Quigley — Updated on Monday, Aug 09, 2010