|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT | ||||||||
javax.xml.bind.annotation Annotation Type XmlSchemaType
@Target(value={FIELD, METHOD, PACKAGE})
将 Java 类型映射到一个简单的模式内置类型。
用法
@XmlSchemaType 注释可以与以下程序元素一起使用:
- JavaBean 属性
- 字段
- 包
为 Java 类型定义的 @XmlSchemaType 注释可应用于所有对属性/字段中的 Java 类型的引用。在属性/字段中指定的 @XmlSchemaType 注释重写在包级别上指定的 @XmlSchemaType 注释。
此注释可与以下注释一起使用:
XmlElement、XmlAttribute。
示例 1:自定义字段上的 XMLGregorianCalendar 的映射。
//Example: Code fragment
public class USPrice {
@XmlElement
@XmlSchemaType(name="date")
public XMLGregorianCalendar date;
}
<!-- Example: Local XML Schema element -->
<xs:complexType name="USPrice"/>
<xs:sequence>
<xs:element name="date" type="xs:date"/>
</sequence>
</xs:complexType>
示例 2:自定义包级别的 XMLGregorianCalendar 的映射。
package foo;
@javax.xml.bind.annotation.XmlSchemaType(
name="date", type=javax.xml.datatype.XMLGregorianCalendar.class)
}
| since | JAXB2.0 |
Maps a Java type to a simple schema built-in type.
Usage
@XmlSchemaType annotation can be used with the following program elements:
- a JavaBean property
- field
- package
@XmlSchemaType annotation defined for Java type applies to all references to the Java type from a property/field. A @XmlSchemaType annotation specified on the property/field overrides the @XmlSchemaType annotation specified at the package level.
This annotation can be used with the following annotations:
XmlElement, XmlAttribute.
Example 1: Customize mapping of XMLGregorianCalendar on the field.
//Example: Code fragment
public class USPrice {
@XmlElement
@XmlSchemaType(name="date")
public XMLGregorianCalendar date;
}
<!-- Example: Local XML Schema element -->
<xs:complexType name="USPrice"/>
<xs:sequence>
<xs:element name="date" type="xs:date"/>
</sequence>
</xs:complexType>
Example 2: Customize mapping of XMLGregorianCalendar at package level
package foo;
@javax.xml.bind.annotation.XmlSchemaType(
name="date", type=javax.xml.datatype.XMLGregorianCalendar.class)
}
- Since:
- JAXB2.0
| Required Element Summary | |
|---|---|
String |
name
|
| Optional Element Summary | |
|---|---|
String |
namespace
|
Class |
type
If this annotation is used at the package level, then value of the type() must be specified. |
| Element Detail |
|---|
abstract public String
name()
英文文档:
name
public abstract String name
abstract public String
namespace()
英文文档:
namespace
public abstract String namespace
- Default:
- "http://www.w3.org/2001/XMLSchema"
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.XmlSchemaType.DEFAULT.class
|
|
|||||||||
| 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 : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!