As we have seen, an object of the class JAXBContext must be constructed as a starting point for other operations. One way is to create a context from a colon separated list of packages.

  1. JAXBContext ctxt = JAXBContext.newInstance( "some foo:more.bar" );

Each package must contain its own class ObjectFactory or a file named jaxb.index. An ObjectFactory class is generated by the XML schema compiler, and therefore this form of newInstance is usually used in connection with schema derived classes. For JAXB annotated Java code, you may use the package path form as well, either with a hand-written ObjectFactory class or with a jaxb.index resource file containing a list of the class names to be considered by JAXB. This file simply lists the class names relative to the package where it occurs, e.g.:

  1. # package some.foo
  2. # class some.foo.Foo
  3. Foo
  4. # inner class some.foo.Foo.Boo
  5. Foo.Boo

An alternative form of the newInstance method lists all classes that the new context should recognize.

  1. JAXBContext ctxt = JAXBContext.newInstance( Foo.class, Bar.class );

Usually, the top level classes are sufficient since JAXB will follow, recursively, all static references, such as the types of instance variables. Subclasses, however, are not included.

If packages or classes are associated with namespaces, the packages or classes associated with a JAXB context also determine the namespace declarations written as attributes into the top-level element of the generated XML document.

JAXB - The JAXB Context的更多相关文章

  1. JAXB注解【转】

    http://blog.csdn.net/lw371496536/article/details/6942045 JAXB(Java API for XML Binding),提供了一个快速便捷的方式 ...

  2. JAXB 注解

    JAXB(Java API for XML Binding),它提供了一个便捷的方式高速Java对象XML转变.于JAX-WS(Java的WebService规范之中的一个)中,JDK1.6 自带的版 ...

  3. 在Gradle中使用jaxb的xjc插件

    jaxb,全称为Java Architecture for Xml Binding,是一种将java对象与xml建立起映射的技术.其主要提供两个功能,一是将java对象映射为xml,二是将xml映射为 ...

  4. Java for XML: JAXP、JAXB、JAXM、JAX-RPC、JAX-WS

    在XML领域里,对XML文件的校验有两种方式:DTD校验.Schema校验.在Java中,对于XML的解析,有多种方式:DOM解析.SAX解析.StAX解析.结合XML和Java后,就产生了Bind技 ...

  5. Jaxb笔记

    摘自: http://www.blogjava.net/eagle-daiq/archive/2012/01/30/369016.html 最近项目原因,研究了下jaxb.jaxb是Java api ...

  6. java JAXB + STAX(是一种针对XML的流式拉分析API)读取xml

    JDK1.5需要添加jar包,1.6以后就不需要了<dependency> <groupId>stax</groupId> <artifactId>st ...

  7. JAXB简单样例

    参考网页:http://www.mkyong.com/java/jaxb-hello-world-example/JAXB完整教程:https://jaxb.java.net/tutorial/1.J ...

  8. java对象与XML相互转化

    起因 最近在公司做了一次webservice相关的任务,其中我最敢兴趣的就是webservice接受到XML对应的流以后是如何方便的转化成java对象,而java对象又是如何生成对应的XML的. 目的 ...

  9. Jersey(1.19.1) - XML Support

    As you probably already know, Jersey uses MessageBodyWriters and MessageBodyReaders to parse incomin ...

随机推荐

  1. HDFS的shell操作

    bin/hadoop命令操作: namenode -format 格式化文件系统 fs(缩写:FileSystem) 运行一个文件系统的用户客户端 bin/hadoop fs常用命令操作: -ls h ...

  2. HW6.11

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  3. Apache Hadoop 源码阅读

    总之一句话,这些都是hadoop-2.2.0的源代码里有的.也就是不光只是懂理论,编程最重要,还是基本功要扎实啊.... 在hadoop-2.2.0的源码里,按Ctrl + Shift + T . 跳 ...

  4. iOS block并发

    多核运算 在iOS中concurrency编程的框架就是GCD(Grand Central Dispatch), GCD的使用非常简单.它把任务分派到不同的queue队列来处理.开发者把任务代码装到一 ...

  5. MVC4的bundling功能简介

    Bundling and Minification是asp.net mvc4中一项可以减少用户请求等待时间,提升用户体验的一项技术.在VS2010中新建MVC4项目是,如果选择"基本&quo ...

  6. FreeModbus for stm32(Keil工程)——精简Modbus slave协议【worlsing笔记】

    FreeModbus For stm32:点击下载源码 1.测试环境Keil MDK 4.7a  stm32f103c8, PB12为输出线圈,    可以通过Modbus Poll来控制线圈的输出状 ...

  7. Oracle- 日期格式和数字类型处理

    更新数据库时间格式的显示格式的语句:(alter session set nls_date_format='YYYY-MM-dd'); to_date("要转换的字符串",&quo ...

  8. sass 使用入门教程

    我们都知道,css没有变量,也没有条件语句,在开发过程中,难免有些麻烦,因此有了CSS预处理器(css preprocessor),Sass便是其中之一. 一.什么是Sass Sass (Syntac ...

  9. IDF实验室-简单编程-特殊的日子 writeup

    题目:http://ctf.idf.cn/index.php?g=game&m=article&a=index&id=50 题目提示要爆破,代表加密应该是不可逆的. 密文:4D ...

  10. linq to sql 扩展方法

    老赵的博客:http://blog.zhaojie.me/2008/02/using-translate-method-and-modify-command-text-before-query-in- ...