HomeDigital EditionSys-Con RadioSearch Java Cd
Advanced Java AWT Book Reviews/Excerpts Client Server Corba Editorials Embedded Java Enterprise Java IDE's Industry Watch Integration Interviews Java Applet Java & Databases Java & Web Services Java Fundamentals Java Native Interface Java Servlets Java Beans J2ME Libraries .NET Object Orientation Observations/IMHO Product Reviews Scalability & Performance Security Server Side Source Code Straight Talking Swing Threads Using Java with others Wireless XML
 

"XML Data Binding with JAXB and UBL"
Vol. 8, Issue 6, p. 50

	



Listing 1

oasis/names/tc/ubl/commonaggregatetypes/_1_0/_0
oasis/names/tc/ubl/corecomponentparameters/_1_0/_0
oasis/names/tc/ubl/corecomponenttypes/_1_0/_0
oasis/names/tc/ubl/despatchadvice/_1_0/_0
oasis/names/tc/ubl/invoice/_1_0/_0
oasis/names/tc/ubl/order/_1_0/_0
oasis/names/tc/ubl/ordercancellation/_1_0/_0
oasis/names/tc/ubl/orderresponse/_1_0/_0
oasis/names/tc/ubl/orderresponsesimple/_1_0/_0
oasis/names/tc/ubl/receiptadvice/_1_0/_0

Listing 2

org/oasis/ubl/commonaggregatetypes
org/oasis/ubl/corecomponentparameters
org/oasis/ubl/corecomponenttypes
org/oasis/ubl/despatchadvice
org/oasis/ubl/invoice
org/oasis/ubl/order
org/oasis/ubl/ordercancellation
org/oasis/ubl/orderresponse
org/oasis/ubl/orderresponsesimple
org/oasis/ubl/receiptadvice

Listing 3

 1 <complexType name="AddressType">
 2   <complexContent>
 3     <restriction base="anyType">
 4       <sequence>
 5         <element ref="ID"/>
 6         <element ref="Postbox" minOccurs="0"/>
 7         <element ref="Building" minOccurs="0"/>
 8         <element ref="Floor" minOccurs="0"/>
 9         <element ref="Room" minOccurs="0"/>
10         <element ref="Street" minOccurs="0"/>
11         <element ref="AdditionalStreet" minOccurs="0"/>
12         <element ref="HouseName" minOccurs="0"/>
13         <element ref="HouseNumber" minOccurs="0"/>
14         <element ref="InhouseMail" minOccurs="0"/>
15         <element ref="Department" minOccurs="0"/>
16         <element ref="CityName" minOccurs="0"/>
17         <element ref="PostalZone" minOccurs="0"/>
18         <element ref="CountrySub-Entity" minOccurs="0"/>
19         <element ref="CountrySub-EntityCode" minOccurs="0"/>
20         <element ref="Region" minOccurs="0"/>
21         <element ref="District" minOccurs="0"/>
22         <element ref="TimezoneOffsetMeasure" minOccurs="0"/>
23         <element ref="Country" minOccurs="0"/>
24       </sequence>
25     </restriction>
26   </complexContent>
27 </complexType>

Listing 4

 1 package org.oasis.ubl.commonaggregatetypes;
 2 
 3 public interface AddressType {
 4 
 5     org.oasis.ubl.corecomponenttypes.TextType getBuilding();
 6     void setBuilding(org.oasis.ubl.corecomponenttypes.TextType value);
 7     org.oasis.ubl.corecomponenttypes.TextType getPostalZone();
 8     void setPostalZone(org.oasis.ubl.corecomponenttypes.TextType value);
 9     org.oasis.ubl.corecomponenttypes.TextType getRoom();
10     void setRoom(org.oasis.ubl.corecomponenttypes.TextType value);
11     org.oasis.ubl.corecomponenttypes.TextType getAdditionalStreet();
12     void setAdditionalStreet(
                          org.oasis.ubl.corecomponenttypes.TextType value);
13     org.oasis.ubl.corecomponenttypes.TextType getDistrict();
14     void setDistrict(org.oasis.ubl.corecomponenttypes.TextType value);
15     org.oasis.ubl.corecomponenttypes.TextType getStreet();
16     void setStreet(org.oasis.ubl.corecomponenttypes.TextType value);
17     org.oasis.ubl.corecomponenttypes.TextType getPostbox();
18     void setPostbox(org.oasis.ubl.corecomponenttypes.TextType value);
19 
20    // Remaining methods omitted ...
21 }

Listing 5: PrintOrder's main() Method

 1 public static void main(String[] args) {
 2     try {
 3         JAXBContext jc =
              JAXBContext.newInstance(
              "org.oasis.ubl.order:"
              + "org.oasis.ubl"
              + ".commonaggregatetypes");
 4         Unmarshaller u =
           jc.createUnmarshaller();
 5         Order order =
              (Order) u.unmarshal(new
                     FileInputStream("0p70/xml/"
                     + "OfficeSupplyOrder"
                     + "Instance.xml"));
 6 
 7         OrderFacade of =
            new OrderFacade(order);
 8         printLetterHead(of);
 9         printDate(of);
10         printBuyer(of);
11         printLineItems(of);
12     } catch (JAXBException e) {
13         e.printStackTrace(System.out);
14     } catch (IOException ioe) {
15         ioe.printStackTrace();
16     }
17 }

Listing 6: PrintOrder's printBuyer() Method

 1 private static void printBuyer(
      OrderFacade order) {
 2     AddressFacade addr =
      order.getBuyerAddress();
 3     System.out.println("\nSold To: "
      + order.getBuyerContact()
      + "\n         c/o "
      + order.getBuyerName()
      + "\n         "
      + addr.getStreet()
      + "\n         "
      + addr.getCity()
      + ", "
      + addr.getState()
      + "  "
      + addr.getZip());
4 }

Listing 7: OrderFacade's getBuyerContact() Method

1  public String getBuyerContact() {
2   BuyerPartyType party = order
	     .getBuyerParty();
3    if (party != null) {
4     if (party.getBuyerContact() != null) {
5         return party.getBuyerContact()
	               .getName() != null
	             ? party.getBuyerContact()
	               .getName().getValue()
	            : null;
6    }
7  }
8  return "";             
9 }

 
 

All Rights Reserved
Copyright ©  2004 SYS-CON Media, Inc.
  E-mail: [email protected]

Java and Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. SYS-CON Publications, Inc. is independent of Sun Microsystems, Inc.