JAXB - Annotations, Annotation for Classes: XmlType

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 {
    ...
}
时间: 2024-11-02 15:39:28

JAXB - Annotations, Annotation for Classes: XmlType的相关文章

JAXB - Annotations, Type Adapters: XmlJavaTypeAdapter

For some Java container types JAXB has no built-in mapping to an XML structure. Also, you may want to represent Java types in a way that is entirely different from what JAXB is apt to do. Such mappings require an adapter class, written as an extensio

JAXB - Annotations, Top-level Elements: XmlRootElement

A class that describes an XML element that is to be a top-level element, i.e., one that can function as an XML document, should be annotated with XmlRootElement. Its optional elements are name and namespace. By default, the class name is used as the

Jaxb annotation初步使用

一.Jaxb处理java对象和xml之间转换常用的annotation有: @XmlType @XmlElement @XmlRootElement @XmlAttribute @XmlAccessorType @XmlAccessorOrder @XmlTransient @XmlJavaTypeAdapter 二.常用annotation使用说明 @XmlType @XmlType用在class类的注解,常与@XmlRootElement,@XmlAccessorType一起使用.它有三个属

XML 注解方式 (Jaxb的使用)

一.Jaxb处理java对象和xml之间转换常用的annotation有: @XmlType @XmlElement @XmlRootElement @XmlAttribute @XmlAccessorType @XmlAccessorOrder @XmlTransient @XmlJavaTypeAdapter 二.常用annotation使用说明 @XmlType @XmlType用在class类的注解,常与@XmlRootElement,@XmlAccessorType一起使用.它有三个属

JAXB注解使用[转]

一.Jaxb处理java对象和xml之间转换常用的annotation有: @XmlType @XmlElement @XmlRootElement @XmlAttribute @XmlAccessorType @XmlAccessorOrder @XmlTransient @XmlJavaTypeAdapter 二.常用annotation使用说明 1.XmlType @XmlType用在class类的注解,常与@XmlRootElement,@XmlAccessorType一起使用.它有三个

Jaxb中的注解关键字说明

一.Jaxb处理java对象和xml之间转换常用的annotation有: @XmlType @XmlElement @XmlRootElement @XmlAttribute @XmlAccessorType @XmlAccessorOrder @XmlTransient @XmlJavaTypeAdapter 二.常用annotation使用说明 @XmlType @XmlType用在class类的注解,常与@XmlRootElement,@XmlAccessorType一起使用.它有三个属

利用JAXB实现java实体类和xml互相转换

1.应用场景 在使用WebService实现数据上传下载,数据查询时,可以利用JAXB实现java实体类和xml互相转换 2.Demo 2.1 student.java 实体类,包含list(set同理).map.Teacher.Date 类型的属性 package jaxb; import java.util.Date; import java.util.List; import java.util.Map; import javax.xml.bind.annotation.XmlAccess

jaxb使用

一.前言 JAXB——Java Architecture for XML Binding,是一项可以根据XML Schema产生Java类的技术.JAXB提供将XML实例文档反向生成Java对象树的方法,也能将Java对象树的内容重新写到XML实例文档. 二.JAXB相关的class和interface (1)JAXBContext.  JAXBContext类提供到 JAXB API 的客户端入口点.它提供了管理实现 JAXB 绑定框架操作所需的 XML/Java 绑定信息的抽象,这些操作包括

Annotation Type @bean,@Import,@configuration使用--官方文档

@Target(value={METHOD,ANNOTATION_TYPE}) @Retention(value=RUNTIME) @Documented public @interface Bean Indicates that a method produces a bean to be managed by the Spring container. Overview The names and semantics of the attributes to this annotation