XmlJavaTypeAdapter (Java EE 5)

Java EE API


javax.xml.bind.annotation.adapters Annotation Type XmlJavaTypeAdapter


@Retention(value=RUNTIME)
@Target(value={PACKAGE,FIELD,METHOD,TYPE,PARAMETER})
public @interface XmlJavaTypeAdapter

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

对自定义编组使用实现 XmlAdapter 的适配器。

用法:

@XmlJavaTypeAdapter 注释可以与下列编程元素一起使用:

当对一个类定义了 @XmlJavaTypeAdapter 注释时,它将适用于该类的所有引用。

当在包级别上定义了 @XmlJavaTypeAdapter 注释时,它将适用于从该包内部到 @XmlJavaTypeAdapter.type() 的所有引用。

当对字段、属性或参数定义了 @XmlJavaTypeAdapter 注释时,注释将仅适用于这些字段、属性或参数。

字段、属性或参数上的 @XmlJavaTypeAdapter 注释重写与字段、属性或参数所引用的类关联的 @XmlJavaTypeAdapter 注释。

类上的 @XmlJavaTypeAdapter 注释重写在该类的包级别上指定的 @XmlJavaTypeAdapter 注释。

此注释可与以下注释一起使用:XmlElementXmlAttributeXmlElementRefXmlElementRefsXmlAnyElement。此注释也可以在包级别与以下注释一起使用: XmlAccessorTypeXmlSchemaXmlSchemaTypeXmlSchemaTypes

示例:请参阅 XmlAdapter 中的示例

英文文档:

Use an adapter that implements XmlAdapter for custom marshaling.

Usage:

The @XmlJavaTypeAdapter annotation can be used with the following program elements:

When @XmlJavaTypeAdapter annotation is defined on a class, it applies to all references to the class.

When @XmlJavaTypeAdapter annotation is defined at the package level it applies to all references from within the package to @XmlJavaTypeAdapter.type().

When @XmlJavaTypeAdapter annotation is defined on the field, property or parameter, then the annotation applies to the field, property or the parameter only.

A @XmlJavaTypeAdapter annotation on a field, property or parameter overrides the @XmlJavaTypeAdapter annotation associated with the class being referenced by the field, property or parameter.

A @XmlJavaTypeAdapter annotation on a class overrides the @XmlJavaTypeAdapter annotation specified at the package level for that class.

This annotation can be used with the following other annotations: XmlElement, XmlAttribute, XmlElementRef, XmlElementRefs, XmlAnyElement. This can also be used at the package level with the following annotations: XmlAccessorType, XmlSchema, XmlSchemaType, XmlSchemaTypes.

Example: See example in XmlAdapter

Since:
JAXB2.0
Version:
$Revision: 1.10 $
Author:
  • Sekhar Vajjhala, Sun Microsystems Inc.
  • Kohsuke Kawaguchi, Sun Microsystems Inc.
See Also:
XmlAdapter

Required Element Summary
 Class<? extends XmlAdapter>
 
Optional Element Summary
 Class
 

Element Detail

abstract public Class<T> value()
指向将 value 类型转换为 bound 类型或将 bound 类型转换为 value 类型的类。更多详细信息,请参阅 XmlAdapter
英文文档:

value

public abstract Class<? extends XmlAdapter> value
Points to the clsss that converts a value type to a bound type or vice versa. See XmlAdapter for more details.

abstract public Class<T> type()
如果此注释用于包级别上,那么必须指定 type() 的值。
英文文档:

type

public abstract Class type
If this annotation is used at the package level, then value of the type() must be specified.

Default:
javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter.DEFAULT.class


Submit a bug or feature

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

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

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