Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "EclipseLink/UserGuide/MOXy/Mapping the Unmappable/Converters"

m (Replacing page with ''''Warning This page is obsolete. Please see ''[http://www.eclipse.org/eclipselink/documentation/ Developing JAXB Applications Using EclipseLink M...')
 
(24 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{EclipseLink_UserGuide
+
'''[[Image:Elug_draft_icon.png|Warning]] This page is obsolete. Please see ''[http://www.eclipse.org/eclipselink/documentation/ Developing JAXB Applications Using EclipseLink MOXy]'' for current information.'''
|info=y
+
|toc=y
+
|eclipselink=y
+
|eclipselinktype=MOXy
+
|api=y
+
|apis= * [http://www.eclipse.org/eclipselink/api/latest/javax/xml/bind/annotation/adapters/XmlAdapter.html XmlAdapter]
+
* [http://www.eclipse.org/eclipselink/api/latest/javax/xml/bind/annotation/adapters/XmlJavaTypeAdapter.html XmlJavaTypeAdapter]
+
}}
+
 
+
= XmlAdapter =
+
 
+
JAXB's '''XmlAdapter''' can be used to map classes that would normally be considered "unmappable" - such as classes that do not have a default no-arg constructor, or classes that do not have a natural XML representation.   In a custom subclass of '''XmlAdapter''', you can define define custom code to convert the unmappable class into something that JAXB can handle.  Then, you can use the '''XmlJavaTypeAdapter''' annotation to indicate that your adapter should be used.
+
 
+
= Example =
+
 
+
Our first example will use the following domain class:
+
 
+
<source lang="java">
+
package example;
+
 
+
import java.util.Currency;
+
 
+
@XmlRootElement
+
@XmlAccessorType(XmlAccessType.FIELD)
+
public class PurchaseOrder {
+
 
+
  private Double amount;
+
 
+
  private Currency currency;
+
 
+
  ...
+
}
+
</source>
+

Latest revision as of 13:19, 30 January 2013

Warning This page is obsolete. Please see Developing JAXB Applications Using EclipseLink MOXy for current information.

Back to the top