Hosted by:
SourceForge.net Logo

Sourceforge
     Project Page
     Donations
     Developer List
     CVS
Site Map
     About JOB
     News
     JOB Usage
     FAQ
     Tutorials
     Features
     Revision Plans
     Known Issues
Downloads
     Stable Build
     Bleeding Edge
     Examples
Contact Us
     Join the JOB Team
     Feature Request
     Bug Report
     Technical Support
Are you tired of XML processing APIs that make you tear your hair out just to get one stupid element? Do you find yourself writing repetitive code to parse XML into a pre-written class? If so (and if not) weep no more. Java Object Binding, an open source project licensed with the BSD license (a license even less restrictive than the popular GNU public license) is here and here to stay.

Java Object Binding is a simple API designed to parse, or marshal xml into pre-written classes and to unmarshal any Java object into XML. Unlike the other data binding APIs (such as JAXB, JiBX, or Castor), JOB doesn't require a schema compiler (as in JAXB) or even a binding definition (as in JiBX and Castor). Also, the XML is received by the methods in JOB in String form. This means that JOB is suitable for use in Java applications which aren't allowed file I/O (such as applets). A simple application of JOB could be as follows:

import com.crs.job.*;

public class Library {

    public String version = "1.0";
    Book[] book;
    private Cd cd;

    public static class Book {
        public int pages = 185;
        public String title = "Everything I have to say";
        public String author = "That, I refuse to say";
        public double id = 1.5678;
    }

    public static class Cd {
        public int tracks = 5;
        public String title = "Going back";
        public String artist = "Living Dead";
        public double id = 1.9872;
    }

    public Library() {
        book = new Book[2];
        book[0] = new Book();
        book[1] = new Book();
        cd = new Cd();

        Binder b = new Binder();

        System.out.println(b.marshal(this));
    }

    public static void main(String[] args) {
        new Library();
    }
}

This would marshal to:

<?xml version="1.0" encoding="UTF-8"?>

<library version="1.0">
    <book pages="185">
        <title>Everything I have to say</title>
        <author>That, I refuse to say</author>
        <id>1.5678</id>
    </book>

    <book pages="185">
        <title>Everything I have to say</title>
        <author>That, I refuse to say</author>
        <id>1.5678</id>
    </book>

    <cd tracks="5">
        <title>Going Back</title>
        <artist>Living Dead</artist>
        <id>1.9872</id>
    </cd>
</library>

Output may vary as the Reflection API can return the array of fields in a different order than what they are written in. But regardless, this is a good, simple example of how powerful JOB can be in XML processing. To view more examples of how JOB can be utilized to ease XML processing, select the Examples link to the left.