• 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);
    }
  • 相关阅读:
    js入门2计算平方
    js入门1
    html入门
    表单的例
    sql概述
    关联规则
    回归分析——logic回归
    聚类分析——动态聚类(K-means)
    聚类分析——层次聚类
    创建一个用递归算法求a的b次方的函数
  • 原文地址:https://www.cnblogs.com/huey/p/5511735.html
Copyright © 2020-2023  润新知