Common Java Cookbook

Edition: 0.19

Download PDF or Read on Scribd

Download Examples (ZIP)

6.6. Obtaining Commons Betwixt

6.6.1. Problem

You need to use Commons Betwixt to serialize and deserialize beans to and from XML documents.

6.6.2. Solution

To use Commons Betwixt in a Maven 2 project, add the following dependency to your project's pom.xml:

Example 6.2. Adding a Dependency on Commons Betwixt

    <dependency>
        <groupId>commons-betwixt</groupId>
        <artifactId>commons-betwixt</artifactId>
        <version>0.8</version>
    </dependency>

If you are not sure what this means, I'd suggest reading Maven: The Definitive Guide. When you depend on a library in Maven 2, all you need to do is add the dependency groupId, artifactId, and version to your project's dependencies. Once you do this, Maven 2 will download the dependency and make it available on your project's classpath.

6.6.3. Discussion

Betwixt allows you to translate from beans to XML and vice versa. Beans are serialized to XML documents using a BeanWriter, and they are read from XML using a BeanReader. The structure of the XML can be automatically generated or customized using an XML document to bind properties to elements or attributes.

6.6.4. See Also

For more information about Commons Betwixt, see the Commons Betwixt project page at http://jcommons.apache.org/betwixt.


Creative Commons License
Common Java Cookbook by Tim O'Brien is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 United States License.
Permissions beyond the scope of this license may be available at http://www.discursive.com/books/cjcook/reference/jakartackbk-PREFACE-1.html. Copyright 2009. Common Java Cookbook Chunked HTML Output. Some Rights Reserved.