To be able to create objects from XML elements, the unmarshaller must have an object factory with methods for creating all sorts of objects. Therefore, each package containing JAXB classes must contain one class ObjectFactory, annotated with XmlRegistry.

@XmlRegistry
public class ObjectFactory {
...
}

Most objects require nothing but a simple create method. But whenever an element has to be represented as a JAXBElement<?>, an additional factory method for wrapping the "pure" Java object of some class Foo into an element of class JAXBElement<Foo> must be provided. This method is then annotated with XmlElementDecl, providing the components of the element's tag name through the attributes namespace and name. This is a snippet from some object factory where an element of TreeType is wrapped into a JAXBElement<TreeType>:

@XmlElementDecl(namespace = "", name = "tree")
public JAXBElement<TreeType> createTree( TreeType value) {
return new JAXBElement<TreeType>(_Tree_QNAME, TreeType.class, null, value);
}

JAXB - Annotations, The Object Factory: XmlRegistry, XmlElementDecl的更多相关文章

  1. 问题-XE8报Object factory for class{xx-xx-xx-xx-xx} is missing. To register it, you can drop component[TFDGUIxWaitCursor] into your project.

    问题现象:XE8开发数据访问程序时放入了FDPhysMSSQLDriverLink1.FDConnection1.FDConnection1.FDQuery1.DBGrid1,设计期没法,运行期报&q ...

  2. JAXB - The Object Factory

    Usually hidden in the middle of the list of the classes derived from the types defined in an XML sch ...

  3. JAXB - Annotations, Controlling Element Selection: XmlAccessorType, XmlTransient

    If JAXB binds a class to XML, then, by default, all public members will be bound, i.e., public gette ...

  4. JAXB - Annotations, The Annotation XmlElement

    The basic annotation for a field that's intended to be an element is XmlElement. It permits you to d ...

  5. JAXB - Annotations, Type Adapters: XmlJavaTypeAdapter

    For some Java container types JAXB has no built-in mapping to an XML structure. Also, you may want t ...

  6. 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 ...

  7. JAXB - Annotations, Annotations for the Schema: XmlSchema

    This annotation can only be used with a package. It defines parameters that are derived from the xsd ...

  8. JAXB - Annotations, Class Fields as Attributes: XmlAttribute

    Provided that XML lets you represent a data item as a single value, there is no cut-and-dried rule f ...

  9. JAXB - Annotations, Type Mapping: XmlSchemaType

    The annotation XmlSchemaType defines a mapping between an arbitrary Java type and a simple schema bu ...

随机推荐

  1. 查看本机IP地址及子网掩码(netmask)

    通常有两种方式来查看本机IP地址及子网掩码,一种是在网路和共享中心中查看网路信息:一种是在cmd命令窗口查看. 下面分别介绍这两种方法: 1.在网路和共享中心中查看本机IP地址及子网掩码 (1)打开控 ...

  2. C#编程中的66个好习惯,你有多少个?(转)

    http://www.cnblogs.com/jxsoft/archive/2012/01/11/2318824.html

  3. SQL中binary 和 varbinary的区别 blob

    binary 和 varbinary固定长度 (binary) 的或可变长度 (varbinary) 的 binary 数据类型. binary [ ( n ) ] 固定长度的 n 个字节二进制数据. ...

  4. P、NP及NPC问题

    关于计算理论的一些概念 —判定问题和最优化问题 —归约 —多项式时间 —抽象问题 —形式语言体系 NPC证明 —一个问题转换为判定问题 —说明问题是NP —一个NPC问题规约到这个问题 —只需要规约到 ...

  5. HDU2686-Matrix & HDU3376-Matrix Again(费用流)

    比较简单的题了. 只需从左上角到右下角找两条路就可以了. 因为每个点只能走一次,所以拆点,限制流量为1. 因为求的是最大值,所以权值取反求最小值. 因为第一个点和最后一个点经过两次,只算一次,最后要减 ...

  6. 【转】可执行程序包括BSS段、数据段、代码段

    可执行程序包括BSS段.数据段.代码段(也称文本段). 一.BSS BSS(Block Started by Symbol)通常是指用来存放程序中未初始化的全局变量和静态变量的一块内存区域.特点是:可 ...

  7. Java之DataInputStream和DataOutputStream-用流操作基本数据类型

    package FileDemo; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.Fi ...

  8. EasyUI datagrid自适应问题解决

    在使用js 动态创建EasyUI datagrid时,如果设置fit为true,在显示的时候数据的高度为固定高度不能自适应 解决办法是把fit设为false. 但这样设置后又有个问题,如果把colum ...

  9. rank() over(partition)的使用

    有的时候会遇到这样的问题,我们需要查询一张表,而且要按照业务排序,比如我需要如下的结果: 地区   日期    费用  产品编号   用户编号 290 201202 258 1             ...

  10. 浅析 ThreadLocal

    一.ThreadLocal类说明 ThreadLocal,很容易让人望文生义,直译"本地线程".ThreadLocal不是一个thread,是thread的局部变量.使用Threa ...