Home | License | API Docs
ShiftOne
Download

AcmeOrder Example

A simple Arbor example

The following example shows the bean classes that would need to be defined to accept the data from a simple "order" XML document.

<acmeOrder id="12345">
	<lineItem sku="231876" quantity="1"/>
	<lineItem sku="765344" quantity="1"/>
	<lineItem sku="887522" quantity="1"/>
	<lineItem sku="248312" quantity="2"/>

	<billingAddress street="502 South Street"
		city="New York" state="NY" zip="10001"/>

	<shippingAddress>
		<street>P.O. Box 10092</street>
		<city>Schenectady</city>
		<state>NY</state>
		<zip>12345</zip>
	</shippingAddress>
</acmeOrder>


Note that attributes of shipping address and billing are expressed differently, but in this example are being treated the same.

public class Address {
	private String street, city, state, zip;

	public void setStreet(int street) {
		this.street = street;
	}

	public void setCity(int city) {
		this.city = city;
	}

	public void setState(int state) {
		this.state = state;
	}

	public void setZip(int zip) {
		this.zip = zip;
	}
}

public class LineItem {
	private int sku, quantity;

	public void setSku(int sku) {
		this.sku = sku;
	}

	public void setQuantity(int quantity) {
		this.quantity = quantity;
	}

}

public class Order {
	private int     orderId;
	private List    lineItems = new ArrayList();
	private Address billing   = new Address();
	private Address shipping  = new Address();

	public void setId(int orderId) {
		this.orderId = orderId;
	}

	public LineItem createLineItem() {
		LineItem lineItem = new LineItem();
		lineItems.add(lineItem);
		return lineItems;
	}

	public Address createBillingAddress() {
		return billing;
	}

	public Address createShippingAddress() {
		return shipping;
	}
}

ShiftOne Arbor 1.4

SourceForge.net Logo
page regenerated 5/26/2005 11:34AM
Jeff Drost