XmlAccessorType (Java EE 5)

Java EE API


javax.xml.bind.annotation Annotation Type XmlAccessorType


@Inherited
@Retention(value=RUNTIME)
@Target(value={PACKAGE,TYPE})
public @interface XmlAccessorType

Implements: Annotation
@Inherited
@Retention(value=RUNTIME)
@Target(value={PACKAGE, TYPE})

控制默认情况下是否对字段或 Javabean 属性进行系列化。

用法

@XmlAccessorType 注释可以与以下程序元素一起使用:

  • 顶层类

有关其他公共信息,请参阅 javax.xml.bind.package javadoc 中的“包规范”。

此注释可控制类中的属性和字段的默认序列化。

包上的 @XmlAccessorType 注释可应用于包中的所有类。继承语义的应用如下:

  • 如果类中有 @XmlAccessorType,则使用它。
  • 如果 @XmlAccessorType 存在于该类的一个超类中,则继承它。
  • 否则,将继承包中的 @XmlAccessorOrder

默认规则:

默认情况下,如果包中不存在 @XmlAccessorType,那么假定使用以下包级别注释。

@XmlAccessorType(XmlAccessType.PUBLIC_MEMBER)
 

默认情况下,如果类中不存在 @XmlAccessorType,并且没有任何超类是使用 @XmlAccessorType 注释的,则假定在类中使用以下默认注释:

@XmlAccessorType(XmlAccessType.PUBLIC_MEMBER)
 

此注释可与以下注释一起使用:XmlTypeXmlRootElementXmlSchemaXmlSchemaTypeXmlSchemaTypesXmlJavaTypeAdapter。在包级别上它还可以与以下注释一起使用:XmlJavaTypeAdapter

英文文档:

Controls whether fields or Javabean properties are serialized by default.

Usage

@XmlAccessorType annotation can be used with the following program elements:

  • package
  • a top level class

See "Package Specification" in javax.xml.bind.package javadoc for additional common information.

This annotation provides control over the default serialization of properties and fields in a class.

The annotation @XmlAccessorType on a package applies to all classes in the package. The following inheritance semantics apply:

  • If there is a @XmlAccessorType on a class, then it is used.
  • Otherwise, if a @XmlAccessorType exists on one of its super classes, then it is inherited.
  • Otherwise, the @XmlAccessorType on a package is inherited.

Defaulting Rules:

By default, if @XmlAccessorType on a package is absent, then the following package level annotation is assumed.

   @XmlAccessorType(XmlAccessType.PUBLIC_MEMBER)
 

By default, if @XmlAccessorType on a class is absent, and none of its super classes is annotated with @XmlAccessorType, then the following default on the class is assumed:

   @XmlAccessorType(XmlAccessType.PUBLIC_MEMBER)
 

This annotation can be used with the following annotations: XmlType, XmlRootElement, XmlAccessorOrder, XmlSchema, XmlSchemaType, XmlSchemaTypes, , XmlJavaTypeAdapter. It can also be used with the following annotations at the package level: XmlJavaTypeAdapter.

Since:
JAXB2.0
Version:
$Revision: 1.9 $
Author:
Sekhar Vajjhala, Sun Microsystems, Inc.
See Also:
XmlAccessType

Optional Element Summary
 XmlAccessType
 

abstract public XmlAccessType value()
指定是否对字段或属性进行系列化。
See also javax.xml.bind.annotation.XmlAccessType
英文文档:

value

public abstract XmlAccessType value
Specifies whether fields or properties are serialized.

See Also:
XmlAccessType
Default:
PUBLIC_MEMBER


Submit a bug or feature

Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.

一看就知道只有菜鸟才干这么无知的事啦。

PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!