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,阐述实现所谓“秒杀”的基本思路. 业务场 ...
随机推荐
- javascript——继承
内容: 1.继承的概念.继承分为那几种继承及各种继承的区别 2.js中有那几种继承方式及各种继承的优缺点 3.总结
- 【Hadoop代码笔记】通过JobClient对Jobtracker的调用详细了解Hadoop RPC
Hadoop的各个服务间,客户端和服务间的交互采用RPC方式.关于这种机制介绍的资源很多,也不难理解,这里不做背景介绍.只是尝试从Jobclient向JobTracker提交作业这个最简单的客户端服务 ...
- leetcode@ [30/76] Substring with Concatenation of All Words & Minimum Window Substring (Hashtable, Two Pointers)
https://leetcode.com/problems/substring-with-concatenation-of-all-words/ You are given a string, s, ...
- Java管道流PipedStream
管道读取流和管道写入流可以像管道一样对接上,管道读取流就可以读取管道写入流写入的数据.需要注意的是需要加入多线程技术,因为单线程,先执行read,会发生死锁,因为read方法是阻塞式的,没有数据的re ...
- hdoj 1002 A + B Problem II
A + B Problem II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- Android 开机默认横竖屏
做Android系统开发时,经常遇到机器开机默认横竖屏问题,现整理如下: 方法一:修改WindowManagerService.java 在这个类中修改int mRotation = 0;这个值即可. ...
- angular ui-route
http://www.cnblogs.com/freeliver54/p/4488141.html
- python os.path模块--转载
os.path.abspath(path) #返回绝对路径 os.path.basename(path) #返回文件名 os.path.commonprefix(list) #返回list(多个路径) ...
- 自定义文件上传的按钮的样式css+js
核心就是一段css遮住了原生的input框,然后用js将文件的值传入到另一个指定的input框中 原文链接 http://geniuscarrier.com/how-to-style-a-html-f ...
- .NET解析HTML库集合
CsQuery AngleSharp Jumony HtmlAgilityPack Fizzler ScrapySharp NSoup