zoukankan      html  css  js  c++  java
  • JAXB

    An enum type is annotated with XmlEnum. It has an optional element value of type java.lang.Class which defines the class used for the values used in the XML representation. Usually, and by default, this is java.lang.String but other types, even numeric ones, are equally possible. For a straightforward enum type, this is sufficient:

    @XmlEnum
    public enum SubElemType {
       //...(enum definition)
    }

    Individual enum constants have to be annotated if there is a difference between the Java name and the string used to represent the value in XML. This is defined with an @XmlEnumValue annotation that is attached to individual enum constants. Its required element defines the XML representation string. If it might be useful for the Java application to have support for the conversion between Java values and XML representations as well, the enum type might define the XML representation as a parameter for the constructor, provide a getter for the XML string and perhaps even a lookup function (fromValue) to convert a string to the enum constant. Such a deluxe version of an enum type is shown below.

    @XmlEnum
    public enum SubElemType {
        @XmlEnumValue("PrMaSig")
        PR_MA_SIG("PrMaSig"),
        @XmlEnumValue("Track1")
        TRACK_1("Track1"),
        // ...(more enum constant definitions)
    
        private final String value;
    
        SubElemType(String v) {
            value = v;
        }
    
        public String value() {
            return value;
        }
    
        public static SubElemType fromValue(String v) {
            for (SubElemType c: SubElemType.values()) {
                if (c.value.equals(v)) {
                    return c;
                }
            }
            throw new IllegalArgumentException(v.toString());
        }
    }
  • 相关阅读:
    mongoose中的versionKey
    Mongodb查询引用
    Mogondb笔记
    jquery.roundabout.js图片叠加3D旋转
    win7下安装curl
    express4.x中路由中间件和挂载路径的关系
    express 设置node_env的环境变量
    ie浏览器不兼容css媒体查询的解决办法
    利用python求解物理学中的双弹簧质能系统详解
    详解用python实现简单的遗传算法
  • 原文地址:https://www.cnblogs.com/huey/p/5512295.html
Copyright © 2011-2022 走看看