|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |
javax.xml.bind.annotation Annotation Type XmlElementWrapper
@Target(value={FIELD, METHOD})
生成一个包装 XML 表示形式的包装器元素。 此元素主要用于生成一个包装集合的包装器 XML 元素。因此,该注释支持以下两种形式的序列化。
//Example:code fragment int[] names; // XML Serialization Form 1 (Unwrapped collection) <names> ...</names> <names> ...</names> // XML Serialization Form 2 ( Wrapped collection ) <wrapperElement> <names> value-of-item </names> <names> value-of-item </names> .... </wrapperElement>
通过使用或不使用具有 nillable 属性的元素,两种序列化的 XML 形式可以表示 null 集合。
使用
@XmlElementWrapper 注释可以与以下程序元素一起使用:
- JavaBean 属性
- 非 static、非 transient 字段
用法受到以下约束的限制:
- 该属性必须是一个集合属性
- 此注释可与以下注释一起使用:
XmlElement
、XmlElements
、XmlElementRef
、XmlElementRefs
、XmlJavaTypeAdapter
。
有关其他公共消息,请参阅 javax.xml.bind.package javadoc 中的“包规范”。
since | JAXB2.0 |
See also | javax.xml.bind.annotation.XmlElement, javax.xml.bind.annotation.XmlElements, javax.xml.bind.annotation.XmlElementRef, javax.xml.bind.annotation.XmlElementRefs |
Generates a wrapper element around XML representation. This is primarily intended to be used to produce a wrapper XML element around collections. The annotation therefore supports two forms of serialization shown below.
//Example: code fragment int[] names; // XML Serialization Form 1 (Unwrapped collection) <names> ... </names> <names> ... </names> // XML Serialization Form 2 ( Wrapped collection ) <wrapperElement> <names> value-of-item </names> <names> value-of-item </names> .... </wrapperElement>
The two serialized XML forms allow a null collection to be represented either by absence or presence of an element with a nillable attribute.
Usage
The @XmlElementWrapper annotation can be used with the following program elements:
- JavaBean property
- non static, non transient field
The usage is subject to the following constraints:
- The property must be a collection property
- This annotation can be used with the following annotations:
XmlElement
,XmlElements
,XmlElementRef
,XmlElementRefs
,XmlJavaTypeAdapter
.
See "Package Specification" in javax.xml.bind.package javadoc for additional common information.
- Since:
- JAXB2.0
- Author:
- Kohsuke Kawaguchi, Sun Microsystems, Inc.
- Sekhar Vajjhala, Sun Microsystems, Inc.
- See Also:
XmlElement
,XmlElements
,XmlElementRef
,XmlElementRefs
Optional Element Summary | |
---|---|
String |
name
Name of the XML wrapper element. |
String |
namespace
XML target namespace of the XML wrapper element. |
boolean |
nillable
If true, the absence of the collection is represented by using xsi:nil='true'. |
abstract public String
name()
XML 包装器元素的名称。默认情况下,XML 包装器元素的名称派生于 JavaBean 属性名称。
英文文档:
name
public abstract String name
- Name of the XML wrapper element. By default, the XML wrapper
element name is derived from the JavaBean property name.
- Default:
- "##default"
abstract public String
namespace()
XML 包装器元素的 XML 目标名称空间。
如果该值为 "##default",则名称空间通过以下方式确定:
-
如果封闭包中包含
XmlSchema
注释,并且其elementFormDefault
为QUALIFIED
,则名称空间为封闭类的名称空间。 - 否则名称空间为 ""(这将导致在默认名称空间中生成非限定的元素)。
namespace
public abstract String namespace
- XML target namespace of the XML wrapper element.
If the value is "##default", then the namespace is determined as follows:
-
If the enclosing package has
XmlSchema
annotation, and itselementFormDefault
isQUALIFIED
, then the namespace of the enclosing class. - Otherwise "" (which produces unqualified element in the default namespace.
-
If the enclosing package has
- Default:
- "##default"
abstract public boolean
nillable()
如果为 true,则使用 xsi:nil='true' 表示集合不存在。否则通过不使用该元素来表示集合不存在。
英文文档:
nillable
public abstract boolean nillable
- If true, the absence of the collection is represented by
using xsi:nil='true'. Otherwise, it is represented by
the absence of the element.
- Default:
- false
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |
Submit a bug or feature
Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.
PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!