Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

EclipseLink/Examples/MOXy/GettingStarted/TheBasics

< EclipseLink‎ | Examples‎ | MOXy‎ | GettingStarted
Revision as of 14:40, 8 January 2010 by Blaise.doughan.oracle.com (Talk | contribs) (Domain Model)

Overview

This example will demonstrate how easy it is to convert objects to XML using EclipseLink MOXy (JAXB).

Domain Model

For this example our domain model will represent customer information.

package example.model;
 
import java.util.ArrayList;
import java.util.List;
 
public class Customer {
 
    private String name;
    private Address address;
    private List<PhoneNumber> phoneNumbers;
 
    public Customer() {
        phoneNumbers = new ArrayList<PhoneNumber>();
    }
 
    public String getName() {
        return name;
    }
 
    public void setName(String name) {
        this.name = name;
    }
 
    public Address getAddress() {
        return address;
    }
 
    public void setAddress(Address address) {
        this.address = address;
    }
 
    public List<PhoneNumber> getPhoneNumbers() {
        return phoneNumbers;
    }
 
    public void setPhoneNumbers(List<PhoneNumber> phoneNumbers) {
        this.phoneNumbers = phoneNumbers;
    }
 
}
package example.model;
 
public class Address {
 
    private String street;
    private String city;
 
    public String getStreet() {
        return street;
    }
 
    public void setStreet(String street) {
        this.street = street;
    }
 
    public String getCity() {
        return city;
    }
 
    public void setCity(String city) {
        this.city = city;
    }
 
}
package example.model;
 
public class PhoneNumber {
 
    private String value;
 
    public String getValue() {
        return value;
    }
 
    public void setValue(String value) {
        this.value = value;
    }
 
}

Back to the top