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);
}

最新文章

  1. BootStrap_03之组件(手风琴、导航)
  2. 第21天 fastlane
  3. python学习之路(一)屌丝逆袭之路
  4. hdu 1016 Prime Ring Problem(DFS)
  5. oracle11g 修改字符集 修改为ZHS16GBK
  6. Android 权限查寻表
  7. 转载 SharePoint【Site Definition 系列】– 创建Content Type
  8. haskell学习笔记_函数
  9. Vue.js 系列教程 ①
  10. R语言学习——数据框
  11. Nodepad++ 进行数据分析操作
  12. python Scrapy 常见问题记录
  13. scrollIntoView 顶部与视图(容器)对齐
  14. PHP系统编程--PHP进程信号处理(转)
  15. Linux上的TIME_WAIT和tcp_fin_timeout
  16. 第6章—渲染web视图—SpringMVC+Thymeleaf 处理表单提交
  17. 50个国内外最棒的C/C++源码站点分享
  18. 20170607 JDBC课堂实践 任务四
  19. centos7 minimal 安装 &amp;网络配置
  20. Java序列化与反序列化学习(一)

热门文章

  1. 50道经典的JAVA编程题(36-40)
  2. 自编译安装nginx
  3. Linux更改默认jdk
  4. 让你系统认识flume及安装和使用flume1.5传输数据到hadoop2.2
  5. 基于memcached的单机轻量级通用缓存库minicached的实现
  6. work2
  7. hdu 4115 (2—SAT)
  8. 幻灯片(jquery实现)
  9. IEnumerable、IEnumerator与yield的学习
  10. 网站WAF的检测