Package org.apache.xmlbeans.samples.enumeration.schemaenum.pricesummary

Examples of org.apache.xmlbeans.samples.enumeration.schemaenum.pricesummary.PriceType


        PriceSummaryDocument summaryDoc = PriceSummaryDocument.Factory.newInstance();
        PriceSummaryDocument.PriceSummary summary = summaryDoc.addNewPriceSummary();

        // Create <price> elements to hold <item> elements according to their
        // price threshold.
        PriceType priceZero = summary.addNewPrice();
        PriceType priceTen = summary.addNewPrice();
        PriceType priceTwenty = summary.addNewPrice();

        // Set the threshold attribute value for the two new elements.
        priceZero.setThreshold(PriceType.Threshold.BELOW_10_DOLLARS);
        priceTen.setThreshold(PriceType.Threshold.BETWEEN_10_AND_20_DOLLARS);
        priceTwenty.setThreshold(PriceType.Threshold.ABOVE_20_DOLLARS);

        // Loop through the purchase order <line-item> elements. If their
        // <price> child element is between 10.00 and 20.00, add the <line-item>
        // to the <price> element whose threshold is 10.00. For those over 20.00,
        // add them to the <price> element whose threshold is 20.00.

        // There don't happen to be any under 10.00, but handle this case anyway.
        LineItem[] items = po.getLineItemArray();
        for (int i = 0; i < items.length; i++)
        {
            LineItem item = items[i];

            if (item.getPrice() < 10.00)
            {

                ItemType newItem = priceZero.addNewItem();
                newItem.setTitle(item.getDescription());
                newItem.xsetQuantity(item.xgetQuantity());
                newItem.setAmount(item.getPrice());

            } else if (item.getPrice() >= 10.00 && item.getPrice() < 20.00)
            {

                ItemType newItem = priceTen.addNewItem();
                newItem.setTitle(item.getDescription());
                newItem.xsetQuantity(item.xgetQuantity());
                newItem.setAmount(item.getPrice());

            } else if (item.getPrice() >= 20.00)
            {

                ItemType newItem = priceTwenty.addNewItem();
                newItem.setTitle(item.getDescription());
                newItem.xsetQuantity(item.xgetQuantity());
                newItem.setAmount(item.getPrice());
            }
        }
View Full Code Here

TOP

Related Classes of org.apache.xmlbeans.samples.enumeration.schemaenum.pricesummary.PriceType

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.