KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > xml > bind > annotation > XmlSeeAlso


1 package javax.xml.bind.annotation;
2
3 import javax.xml.bind.JAXBContext;
4 import java.lang.annotation.ElementType JavaDoc;
5 import java.lang.annotation.Retention JavaDoc;
6 import static java.lang.annotation.RetentionPolicy.RUNTIME JavaDoc;
7 import java.lang.annotation.Target JavaDoc;
8
9 /**
10  * Instructs JAXB to also bind other classes when binding this class.
11  *
12  * <p>
13  * Java makes it impractical/impossible to list all sub-classes of
14  * a given class. This often gets in a way of JAXB users, as it JAXB
15  * cannot automatically list up the classes that need to be known
16  * to {@link JAXBContext}.
17  *
18  * <p>
19  * For example, with the following class definitions:
20  *
21  * <pre>
22  * class Animal {}
23  * class Dog extends Animal {}
24  * class Cat extends Animal {}
25  * </pre>
26  *
27  * <p>
28  * The user would be required to create {@link JAXBContext} as
29  * <tt>JAXBContext.newInstance(Dog.class,Cat.class)</tt>
30  * (<tt>Animal</tt> will be automatically picked up since <tt>Dog</tt>
31  * and <tt>Cat</tt> refers to it.)
32  *
33  * <p>
34  * {@link XmlSeeAlso} annotation would allow you to write:
35  * <pre>
36  * &#64;XmlSeeAlso({Dog.class,Cat.class})
37  * class Animal {}
38  * class Dog extends Animal {}
39  * class Cat extends Animal {}
40  * </pre>
41  *
42  * <p>
43  * This would allow you to do <tt>JAXBContext.newInstance(Animal.class)</tt>.
44  * By the help of this annotation, JAXB implementations will be able to
45  * correctly bind <tt>Dog</tt> and <tt>Cat</tt>.
46  *
47  * @author Kohsuke Kawaguchi
48  * @since JAXB2.1
49  * @version $Revision: $
50  */

51 @Target JavaDoc({ElementType.TYPE})
52 @Retention JavaDoc(RUNTIME)
53 public @interface XmlSeeAlso {
54     Class JavaDoc[] value();
55 }
Popular Tags