< prev index next >
src/java.xml.bind/share/classes/javax/xml/bind/annotation/adapters/XmlAdapter.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 74,118 ****
* customize the mapping of a <tt>HashMap</tt>.
*
* <p> <b> Step 1: </b> Determine the desired XML representation for HashMap.
*
* <pre>
! * <hashmap>
! * <entry key="id123">this is a value</entry>
! * <entry key="id312">this is another value</entry>
* ...
! * </hashmap>
* </pre>
*
* <p> <b> Step 2: </b> Determine the schema definition that the
* desired XML representation shown above should follow.
*
* <pre>
*
! * <xs:complexType name="myHashMapType">
! * <xs:sequence>
* <xs:element name="entry" type="myHashMapEntryType"
! * minOccurs = "0" maxOccurs="unbounded"/>
! * </xs:sequence>
! * </xs:complexType>
! *
! * <xs:complexType name="myHashMapEntryType">
! * <xs:simpleContent>
! * <xs:extension base="xs:string">
! * <xs:attribute name="key" type="xs:int"/>
! * </xs:extension>
! * </xs:simpleContent>
! * </xs:complexType>
*
* </pre>
*
* <p> <b> Step 3: </b> Write value types that can generate the above
* schema definition.
*
* <pre>
* public class MyHashMapType {
! * List<MyHashMapEntryType> entry;
* }
*
* public class MyHashMapEntryType {
* @XmlAttribute
* public Integer key;
--- 74,118 ----
* customize the mapping of a <tt>HashMap</tt>.
*
* <p> <b> Step 1: </b> Determine the desired XML representation for HashMap.
*
* <pre>
! * <hashmap>
! * <entry key="id123">this is a value</entry>
! * <entry key="id312">this is another value</entry>
* ...
! * </hashmap>
* </pre>
*
* <p> <b> Step 2: </b> Determine the schema definition that the
* desired XML representation shown above should follow.
*
* <pre>
*
! * <xs:complexType name="myHashMapType">
! * <xs:sequence>
* <xs:element name="entry" type="myHashMapEntryType"
! * minOccurs = "0" maxOccurs="unbounded"/>
! * </xs:sequence>
! * </xs:complexType>
! *
! * <xs:complexType name="myHashMapEntryType">
! * <xs:simpleContent>
! * <xs:extension base="xs:string">
! * <xs:attribute name="key" type="xs:int"/>
! * </xs:extension>
! * </xs:simpleContent>
! * </xs:complexType>
*
* </pre>
*
* <p> <b> Step 3: </b> Write value types that can generate the above
* schema definition.
*
* <pre>
* public class MyHashMapType {
! * List<MyHashMapEntryType> entry;
* }
*
* public class MyHashMapEntryType {
* @XmlAttribute
* public Integer key;
*** 125,135 ****
* <p> <b> Step 4: </b> Write the adapter that adapts the value type,
* MyHashMapType to a bound type, HashMap, used by the application.
*
* <pre>
* public final class MyHashMapAdapter extends
! * XmlAdapter<MyHashMapType,HashMap> { ... }
*
* </pre>
*
* <p> <b> Step 5: </b> Use the adapter.
*
--- 125,135 ----
* <p> <b> Step 4: </b> Write the adapter that adapts the value type,
* MyHashMapType to a bound type, HashMap, used by the application.
*
* <pre>
* public final class MyHashMapAdapter extends
! * XmlAdapter<MyHashMapType,HashMap> { ... }
*
* </pre>
*
* <p> <b> Step 5: </b> Use the adapter.
*
*** 142,156 ****
* </pre>
*
* The above code fragment will map to the following schema:
*
* <pre>
! * <xs:complexType name="Foo">
! * <xs:sequence>
! * <xs:element name="hashmap" type="myHashMapType"
! * </xs:sequence>
! * </xs:complexType>
* </pre>
*
* @param <BoundType>
* The type that JAXB doesn't know how to handle. An adapter is written
* to allow this type to be used as an in-memory representation through
--- 142,156 ----
* </pre>
*
* The above code fragment will map to the following schema:
*
* <pre>
! * <xs:complexType name="Foo">
! * <xs:sequence>
! * <xs:element name="hashmap" type="myHashMapType">
! * </xs:sequence>
! * </xs:complexType>
* </pre>
*
* @param <BoundType>
* The type that JAXB doesn't know how to handle. An adapter is written
* to allow this type to be used as an in-memory representation through
< prev index next >