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

    /* 首字母变大写 Problem Description 输入一个英文句子,将每个单词的第一个字母改成大写字母.   Input 输入数据包含多个测试实例,每个测试实例是一个长度不超过100的英文句 ...

  2. Python引用传值总结

    Python函数的参数传值使用的是引用传值,也就是说传的是参数的内存地址值,因此在函数中改变参数的值,函数外也会改变. 这里需要注意的是如果传的参数类型是不可改变的,如String类型.元组类型,函数 ...

  3. Sort--冒泡排序

    冒泡排序 public class BubbleSort { public static void bubblesort(int[] a){ for(int i=0;i<a.length-1;i ...

  4. Unity3D实现简单的抽奖程序

    下面是具体的代码,注意,我这里用到了NGUI这个插件.大概的原理很简单,就用了2张图片Sprite,同时向下移动,当上面一张图片移动到下面一张图片原来的位置时,就把这2张图片向上移到初始的位置.这时, ...

  5. hdoj 1402 Prepared for New Acmer【快速幂】

    Prepared for New Acmer Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/O ...

  6. UVa123 - Searching Quickly

    题目地址:点击打开链接 C++代码: #include <iostream> #include <set> #include <map> #include < ...

  7. 【C++深入浅出】设计模式学习之观察者模式

    前言 前两天学习了weak_ptr以后还是不甚明了,一则需要实际应用去锤炼,二来就是不懂观察者模式. 正文 观察者模式又叫发布-订阅模式,定义了一种一对多的依赖关系,让多个观察者对象同时监听某一主题对 ...

  8. JavaScript 要点(十四)HTML DOM 元素(节点)

    A.创建新的 HTML 元素 如需向 HTML DOM 添加新元素,必须首先创建该元素(元素节点),然后向一个已存在的元素追加该元素. <div id="div1"> ...

  9. 如何让OpenSSL得到JKS格式的keystore中的public and private key

    国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html内部邀请码:C8E245J (不写邀请码,没有现金送)国内私 ...

  10. Postfix 电子邮件系统精要

    来源: http://sery.blog.51cto.com/10037/45500 Postfix 电子邮件系统精要 作者:田逸(sery@163.com)  from [url]http://ww ...