JAXB - Annotations, Annotations for Enums: XmlEnum, XmlEnumValue
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());
}
}
JAXB - Annotations, Annotations for Enums: XmlEnum, XmlEnumValue的更多相关文章
- JAXB - Annotations, Annotations for the Schema: XmlSchema
This annotation can only be used with a package. It defines parameters that are derived from the xsd ...
- Table of Contents - JAXB
Getting Started Hello World Hello World with Namespace xjc - 将 XML Schema 编译成 Java 类 wsimport: 编译 WS ...
- How Do Annotations Work in Java?--转
原文地址:https://dzone.com/articles/how-annotations-work-java Annotations have been a very important par ...
- ABAP CDS - Annotations 注解
Syntax ... annotation[.annotation1[.annotation2]][:value] ... Effect Annotation that can be specifi ...
- Domain Driven Design and Development In Practice--转载
原文地址:http://www.infoq.com/articles/ddd-in-practice Background Domain Driven Design (DDD) is about ma ...
- Android 网络框架之Retrofit2使用详解及从源码中解析原理
就目前来说Retrofit2使用的已相当的广泛,那么我们先来了解下两个问题: 1 . 什么是Retrofit? Retrofit是针对于Android/Java的.基于okHttp的.一种轻量级且安全 ...
- Java中的反射和注解
前言 在Java中,反射机制和注解机制一直是一个很重要的概念,那么他们其中的原理是怎么样呢,我们不仅仅需要会使用,更要知其然而之所以然. 目录 反射机制 反射如何使用 注解定义 注解机制原理 注解如何 ...
- Thinking in Java——笔记(20)
Annotations They provide information that you need to fully describe your program, but that cannot b ...
- 基于redis分布式锁实现“秒杀”
转载:http://blog.5ibc.net/p/28883.html 最近在项目中遇到了类似“秒杀”的业务场景,在本篇博客中,我将用一个非常简单的demo,阐述实现所谓“秒杀”的基本思路. 业务场 ...
随机推荐
- Django ORM 中的批量操作
Django ORM 中的批量操作 在Hibenate中,通过批量提交SQL操作,部分地实现了数据库的批量操作.但在Django的ORM中的批量操作却要完美得多,真是一个惊喜. 数据模型定义 首先,定 ...
- AndroidManifest笔记
1.android:configChanges如果配置了这个值,比如"orientation",在屏幕旋转时会调用Activity的onConfigurationChanged,而 ...
- Java & XML Tool Overview
As mentioned in the introduction Sun now provides these tools for XML Processing in Java: StAX Reade ...
- jquery中 cache: true和false的区别
true:会读缓存,可能真的到服务器上. 假如上次访问了a.html,第二次的时候得到的是上次访问的a.html的结果,而不是重新到服务器获取. false:会在url后面加一个时间缀,让它跑到服务器 ...
- 设计Account 对象如下: private long id; private double balance; private String password; 要求完善设计,使得该Account 对象能够自动分配id。 给定一个List 如下:
package homework005; public class Account { private long id; private double balance; private String ...
- Qt 经典出错信息之”Basic XLib functionality test failed!”(Z..z..)
此完整出错信息是在./configure阶段 Basic XLib functionality test failed! You might need to modify the include an ...
- JS知识点备忘
做前端久了,会发现很多比较杂的知识点,平时很少用到(往往在面试的时候经常见到),但是遇到的时候会很揪心...所以遇到的时候把它记录下来,但求有个印象,再次遇到时,可以在这里快速找到解决. 1.文档碎片 ...
- PCL入门—点云操作 定义变量 显示点云 存储
// 定义相关变量 pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_ptr (new pcl::PointCloud<pcl::PointXYZ& ...
- 百度之星资格赛,hdu 4825 XOR SUM
显然是要建一棵0.1树 事实上非常easy就是二叉树,仅仅只是为了操作简便,即程序的速度,所以就採用静态树,即不动态分配内存,使用较大的全局数组.0是根节点 #include<cstdio> ...
- android131 360 04 手机安全页面
## Root权限 ## > 什么是Root权限? Root权限相当于系统管理员权限, 有了root权限,就可以随意修改和删除手机内部的文件. > 一般手机购买之后, 都没有root权限. ...