Java 2EE and XML Development

Скачать в pdf «Java 2EE and XML Development»


String description = null;


List descriptions = product.getDescription();


ListIterator it = descriptions.listIterator();


while (it.hasNext()) {


Description d = (Description) it.next(); if (d.getLocale().equals(en_US)) { description = d.getDescription(); break;


}


}


This type of iteration is necessary when processing XML data through all APIs, and is not specific to JAXB. It is a necessary part of traversing tree data structures like XML.


We invite you to explore the full capabilities of JAXB at the URL given near the beginning of this section. This can be a very useful API in certain applications, especially those with serious performance demands.

2.2.4 Long Term JavaBeans Persistence


Easily the most poorly named Java XML API, Long Term JavaBeans Persistence defines an XML mapping API for JavaBeans components. It is similar in function to JAXB, but leverages the JavaBeans component contract instead of a binding schema to define the mapping from Java to XML. Since JavaBeans must define get and set methods for each of their publicly accessible properties, it was possible to develop XML-aware components that can serialize JavaBeans to XML without a binding schema. These components use the Java reflection API to inspect a given bean and serialize it to XML in a standard format.


This API has become a part of the Java 2 Standard Edition as of version 1.4. There is no need to download any extra classes and add them to your classpath. The primary interfaces to this API are summarized in table 2.8. These classes behave in a similar fashion to java.io.ObjectInputStream and java.io.ObjectOutputStream, but use XML instead of a binary format.

Скачать в pdf «Java 2EE and XML Development»