zoukankan      html  css  js  c++  java
  • JAXB

    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);
    }
  • 相关阅读:
    省选测试29
    省选测试28
    省选测试27
    省选测试26
    省选测试25
    最小费用最大流Dinic
    省选测试24
    省选测试23
    省选测试22
    省选测试21
  • 原文地址:https://www.cnblogs.com/huey/p/5511735.html
Copyright © 2011-2022 走看看