1 /* 2 * Copyright (c) 2005, 2010, 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.annotation.adapters.XmlJavaTypeAdapter; 29 import java.lang.annotation.Target; 30 import java.lang.annotation.Retention; 31 import java.lang.annotation.Inherited; 32 33 import static java.lang.annotation.ElementType.*; 34 import static java.lang.annotation.RetentionPolicy.*; 35 36 /** 37 * <p> Controls whether fields or Javabean properties are serialized by default. </p> 38 * 39 * <p> <b> Usage </b> </p> 40 * 41 * <p> <tt>@XmlAccessorType</tt> annotation can be used with the following program elements:</p> 42 * 43 * <ul> 44 * <li> package</li> 45 * <li> a top level class </li> 46 * </ul> 47 * 48 * <p> See "Package Specification" in javax.xml.bind.package javadoc for 49 * additional common information.</p> 50 * 51 * <p>This annotation provides control over the default serialization 52 * of properties and fields in a class. 53 * 54 * <p>The annotation <tt> @XmlAccessorType </tt> on a package applies to 55 * all classes in the package. The following inheritance 56 * semantics apply: 57 * 58 * <ul> 59 * <li> If there is a <tt>@XmlAccessorType</tt> on a class, then it 60 * is used. </li> 61 * <li> Otherwise, if a <tt>@XmlAccessorType</tt> exists on one of 62 * its super classes, then it is inherited. 63 * <li> Otherwise, the <tt>@XmlAccessorType </tt> on a package is 64 * inherited. 65 * </ul> 66 * <p> <b> Defaulting Rules: </b> </p> 67 * 68 * <p>By default, if <tt>@XmlAccessorType </tt> on a package is absent, 69 * then the following package level annotation is assumed.</p> 70 * <pre> 71 * @XmlAccessorType(XmlAccessType.PUBLIC_MEMBER) 72 * </pre> 73 * <p> By default, if <tt>@XmlAccessorType</tt> on a class is absent, 74 * and none of its super classes is annotated with 75 * <tt>@XmlAccessorType</tt>, then the following default on the class 76 * is assumed: </p> 77 * <pre> 78 * @XmlAccessorType(XmlAccessType.PUBLIC_MEMBER) 79 * </pre> 80 * <p>This annotation can be used with the following annotations: 81 * {@link XmlType}, {@link XmlRootElement}, {@link XmlAccessorOrder}, 82 * {@link XmlSchema}, {@link XmlSchemaType}, {@link XmlSchemaTypes}, 83 * , {@link XmlJavaTypeAdapter}. It can also be used with the 84 * following annotations at the package level: {@link XmlJavaTypeAdapter}. 85 * 86 * @author Sekhar Vajjhala, Sun Microsystems, Inc. 87 * @since JAXB2.0 88 * @see XmlAccessType 89 */ 90 91 @Inherited @Retention(RUNTIME) @Target({PACKAGE, TYPE}) 92 public @interface XmlAccessorType { 93 94 /** 95 * Specifies whether fields or properties are serialized. 96 * 97 * @see XmlAccessType 98 */ 99 XmlAccessType value() default XmlAccessType.PUBLIC_MEMBER; 100 }