12009
|
1 |
/*
|
|
2 |
* Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
|
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation. Oracle designates this
|
|
8 |
* particular file as subject to the "Classpath" exception as provided
|
|
9 |
* by Oracle in the LICENSE file that accompanied this code.
|
|
10 |
*
|
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
15 |
* accompanied this code).
|
|
16 |
*
|
|
17 |
* You should have received a copy of the GNU General Public License version
|
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
20 |
*
|
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
22 |
* or visit www.oracle.com if you need additional information or have any
|
|
23 |
* questions.
|
|
24 |
*/
|
|
25 |
|
|
26 |
package javax.xml.bind.annotation;
|
|
27 |
|
|
28 |
import javax.xml.bind.JAXBContext;
|
|
29 |
import java.lang.annotation.ElementType;
|
|
30 |
import java.lang.annotation.Retention;
|
|
31 |
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
|
32 |
import java.lang.annotation.Target;
|
|
33 |
|
|
34 |
/**
|
|
35 |
* Instructs JAXB to also bind other classes when binding this class.
|
|
36 |
*
|
|
37 |
* <p>
|
|
38 |
* Java makes it impractical/impossible to list all sub-classes of
|
|
39 |
* a given class. This often gets in a way of JAXB users, as it JAXB
|
|
40 |
* cannot automatically list up the classes that need to be known
|
|
41 |
* to {@link JAXBContext}.
|
|
42 |
*
|
|
43 |
* <p>
|
|
44 |
* For example, with the following class definitions:
|
|
45 |
*
|
|
46 |
* <pre>
|
|
47 |
* class Animal {}
|
|
48 |
* class Dog extends Animal {}
|
|
49 |
* class Cat extends Animal {}
|
|
50 |
* </pre>
|
|
51 |
*
|
|
52 |
* <p>
|
|
53 |
* The user would be required to create {@link JAXBContext} as
|
|
54 |
* <tt>JAXBContext.newInstance(Dog.class,Cat.class)</tt>
|
|
55 |
* (<tt>Animal</tt> will be automatically picked up since <tt>Dog</tt>
|
|
56 |
* and <tt>Cat</tt> refers to it.)
|
|
57 |
*
|
|
58 |
* <p>
|
|
59 |
* {@link XmlSeeAlso} annotation would allow you to write:
|
|
60 |
* <pre>
|
|
61 |
* @XmlSeeAlso({Dog.class,Cat.class})
|
|
62 |
* class Animal {}
|
|
63 |
* class Dog extends Animal {}
|
|
64 |
* class Cat extends Animal {}
|
|
65 |
* </pre>
|
|
66 |
*
|
|
67 |
* <p>
|
|
68 |
* This would allow you to do <tt>JAXBContext.newInstance(Animal.class)</tt>.
|
|
69 |
* By the help of this annotation, JAXB implementations will be able to
|
|
70 |
* correctly bind <tt>Dog</tt> and <tt>Cat</tt>.
|
|
71 |
*
|
|
72 |
* @author Kohsuke Kawaguchi
|
|
73 |
* @since JAXB2.1
|
|
74 |
*/
|
|
75 |
@Target({ElementType.TYPE})
|
|
76 |
@Retention(RUNTIME)
|
|
77 |
public @interface XmlSeeAlso {
|
|
78 |
Class[] value();
|
|
79 |
}
|