Package org.dom4j.test.primer

Examples of org.dom4j.test.primer.PurchaseOrder


* @author Wonne Keysers (Realsoftware.be)
*/
public class PurchaseOrderHandler implements JAXBObjectHandler {

    public void handleObject(Element jaxbElement) throws Exception {
        PurchaseOrder order = (PurchaseOrder) jaxbElement;
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");

        System.out.println("Order - id:" + order.getId() + ", date:"
                + format.format(order.getOrderDate().getTime()));
    }
View Full Code Here


* @author Wonne Keysers (Realsoftware.be)
*/
public class PurchaseOrderDateModifier implements JAXBObjectModifier {

    public Element modifyObject(Element jaxbElement) throws Exception {
        PurchaseOrder order = (PurchaseOrder) jaxbElement;

        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(System.currentTimeMillis());
        order.setOrderDate(calendar);

        return order;
    }
View Full Code Here

            ObjectFactory factory = new ObjectFactory();

            PurchaseOrders orders = factory.createPurchaseOrders();

            // Order 1
            PurchaseOrder order = factory.createPurchaseOrder();

            USAddress billTo = factory.createUSAddress();
            billTo.setCity("Cambridge");
            billTo.setCountry("US");
            billTo.setName("Robert Smith");
            billTo.setState("MA");
            billTo.setStreet("8 Oak Avenue");
            billTo.setZip(new BigDecimal(12345));
            order.setBillTo(billTo);

            USAddress shipTo = factory.createUSAddress();
            shipTo.setCity("Cambridge");
            shipTo.setCountry("US");
            shipTo.setName("Alice Smith");
            shipTo.setState("MA");
            shipTo.setStreet("123 Maple Street");
            shipTo.setZip(new BigDecimal(12345));
            order.setShipTo(shipTo);

            Calendar orderDate = Calendar.getInstance();
            orderDate.set(2004, 06, 30);
            order.setOrderDate(orderDate);

            Items items = factory.createItems();
            order.setItems(items);

            orders.getPurchaseOrder().add(order);

            // Order 2
            PurchaseOrder order2 = factory.createPurchaseOrder();

            USAddress billTo2 = factory.createUSAddress();
            billTo2.setCity("Cambridge");
            billTo2.setCountry("US");
            billTo2.setName("Robert Smith");
            billTo2.setState("MA");
            billTo2.setStreet("8 Oak Avenue");
            billTo2.setZip(new BigDecimal(12345));
            order2.setBillTo(billTo2);

            USAddress shipTo2 = factory.createUSAddress();
            shipTo2.setCity("Cambridge");
            shipTo2.setCountry("US");
            shipTo2.setName("Alice Smith");
            shipTo2.setState("MA");
            shipTo2.setStreet("123 Maple Street");
            shipTo2.setZip(new BigDecimal(12345));
            order2.setShipTo(shipTo2);

            Calendar orderDate2 = Calendar.getInstance();
            orderDate2.set(2004, 06, 30);
            order2.setOrderDate(orderDate2);

            Items items2 = factory.createItems();
            order2.setItems(items2);

            orders.getPurchaseOrder().add(order2);

            File outputFile = new File(outputDir, "jaxbWrite.xml");
View Full Code Here

TOP

Related Classes of org.dom4j.test.primer.PurchaseOrder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.