JAXB - Annotations, The Object Factory: XmlRegistry, XmlElementDecl
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的更多相关文章
- 问题-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 ...
- JAXB - The Object Factory
Usually hidden in the middle of the list of the classes derived from the types defined in an XML sch ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- JAXB - Annotations, Type Mapping: XmlSchemaType
The annotation XmlSchemaType defines a mapping between an arbitrary Java type and a simple schema bu ...
随机推荐
- 【转】getopt分析命令行参数
(一) 在Linux中,用命令行执行可执行文件时可能会涉及到给其加入不同的参数的问题,例如: ./a.out -a1234 -b432 -c -d 程序会根据读取的参数执行相应的操作,在C语言中,这个 ...
- HDU-4704 Sum 大数幂取模
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4704 题意:求a^n%m的结果,其中n为大数. S(1)+S(2)+...+S(N)等于2^(n-1) ...
- POJ 3648-Wedding(2-SAT)
题面很邪恶啊... 一对新人请n-1对夫妻吃饭,人们坐在一张桌子的两侧,每一对互为夫妻关系的人必须坐在桌子的两侧.而且有些人两两之间会存在“通奸”关系,通奸关系不仅在男女之间,同性之间也有.新娘对面不 ...
- 10行Java代码实现最近被使用(LRU)缓存
在最近的面试中,我曾被多次问到,怎么实现一个最近最少使用(LRU)的缓存.缓存可以通过哈希表来实现,然而为这个缓存增加大小限制会变成另一个有意思的问题.现在我们看一下怎么实现. 最近最少使用缓存的回收 ...
- 你可能没听过的 Java 8 中的 10 个特性
你以前听到的谈论关于Java8的所有都是围绕lambda表达式. 但它仅仅是Java8的一部分. Java 8 有许多新特性—一些强大的新类和语法, 还有其他的从一开始就应该具有的东西. 我将要介绍我 ...
- ubuntu 忘记用户名及密码解决办法
1.重启系统 2.长按Shift键,直到出现菜单.选择recovery mode,即恢复模式 3.选择root 4.# 后面敲入 cat /etc/shadow 查看用户名 5.# passwd & ...
- 从最近MySQL的优化工作想到的
最近决定将以前同事写的存储过程查看一遍,寻找一些代码上写的不太好的地方,争取进行修改以后让这些过程达到一个很好的运行速度.下面是遇到的最多的几个问题. 我遇到了这样的一个SQL: select nam ...
- python会什么比c慢
众所周知,python执行速度比c慢.原因为何? 先来看下面这张图: python的传统运行执行模式:录入的源代码转换为字节码,之后字节码在python虚拟机中运行.代码自动被编译,之后再解释成机器码 ...
- .@RequestMapping 使用方法
1.@RequestMapping 使用方法 SpringMVC中,@RequestMapping用来处理请求,比方XXX.do @RequestMapping("/aaa") ...
- ThinkPHP CURD方法盘点:order方法
order方法属于模型的连贯操作方法之一,用于对操作的结果排序. 用法 $Model->where('status=1')->order('id desc')->limit(5)-& ...