background image

Unmarshal Real Example

<< USAddress.java Class Code | JAXBContext instance >>
<< USAddress.java Class Code | JAXBContext instance >>
B
ASIC
E
XAMPLES
29
void setState(String value);
java.math.BigDecimal getZip();
void setZip(java.math.BigDecimal value);
String getCountry();
void setCountry(String value);
String getCity();
void setCity(String value);
String getStreet();
void setStreet(String value);
String getName();
void setName(String value);
}
Basic Examples
This section describes the Basic examples (Unmarshal Read, Modify Marshal,
Unmarshal Validate) that demonstrate how to:
· Unmarshal an XML document into a Java content tree and access the data
contained within it
· Modify a Java content tree
· Use the
ObjectFactory
class to create a Java content tree from scratch and
then marshal it to XML data
· Perform validation during unmarshalling
· Validate a Java content tree at runtime
Unmarshal Read Example
The purpose of the Unmarshal Read example is to demonstrate how to unmar-
shal an XML document into a Java content tree and access the data contained
within it.
1. The
<INSTALL>/examples/jaxb/unmarshal-read/
Main.java
class declares imports for four standard Java classes plus three
JAXB binding framework classes and the
primer.po
package:
import java.io.FileInputStream
import java.io.IOException
import java.util.Iterator
import java.util.List
import javax.xml.bind.JAXBContext
import javax.xml.bind.JAXBException