码迷,mamicode.com
首页 > 其他好文 > 详细

JAXB - Annotations, Annotation for Classes: XmlType

时间:2016-05-20 13:11:59      阅读:105      评论:0      收藏:0      [点我收藏+]

标签:

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 titleitems and cluster should appear in the given order:

@XmlRootElement
@XmlType( propOrder={ "title", "items", "cluster" } )
public class Document {
    ...
}

 

JAXB - Annotations, Annotation for Classes: XmlType

标签:

原文地址:http://www.cnblogs.com/huey/p/5511701.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!