zoukankan      html  css  js  c++  java
  • JAXB

    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.

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

    # package some.foo
    # class some.foo.Foo
    Foo
    # inner class some.foo.Foo.Boo
    Foo.Boo

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

    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.

  • 相关阅读:
    Using the proxy page
    ArcGIS 帮助 10.1 几何服务
    【转】地图投影系列介绍(三)_ 地图投影
    最简单的闰年函数
    JSP的编码问题
    和苗波玩吉他英雄,还有诺拉斯战士
    倒底是用接口,还是继承类?
    收集的两个Winform三层结构的例子
    在vs.net 2005 中 像JBuilder,Eclipse那样格式化代码
    JSP比ASP好的几个地方
  • 原文地址:https://www.cnblogs.com/huey/p/5511196.html
Copyright © 2011-2022 走看看