您的位置:首页 > 其它

JAXB - Annotations, Annotation for Classes: XmlType

2016-05-20 12:56 357 查看
This annotation adds information that would be available from a schema type, but isn't implied by a Java class declaration. The annotation has several attributes:

factoryClass
and
factoryMethod
define the class containing a no-argument method for creating an instance of this class as the equivalent of an empty XML element.

The attribute
name
provides the XML schema name if you don't want to use the class name.

The
namespace
attribute provides the name of the target namespace.

The string array value defined by
propOrder
establishes an ordering of the sub-elements. (It's pretty obvious that there can't be a connection between the textual order of items in a class definition and the order its fields are returned by reflection methods.)

Here is an example for
XmlType
, requesting that the elements
title
,
items
and
cluster
should appear in the given order:

@XmlRootElement
@XmlType( propOrder={ "title", "items", "cluster" } )
public class Document {
...
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: