001/* 002 * Version.java July 2008 003 * 004 * Copyright (C) 2008, Niall Gallagher <niallg@users.sf.net> 005 * 006 * Licensed under the Apache License, Version 2.0 (the "License"); 007 * you may not use this file except in compliance with the License. 008 * You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 015 * implied. See the License for the specific language governing 016 * permissions and limitations under the License. 017 */ 018 019package org.simpleframework.xml; 020 021import java.lang.annotation.Retention; 022import java.lang.annotation.RetentionPolicy; 023 024/** 025 * The <code>Version</code> annotation is used to specify an attribute 026 * that is used to represent a revision of the class XML schema. This 027 * annotation can annotate only floating point types such as double, 028 * float, and the java primitive object types. This can not be used to 029 * annotate strings, enumerations or other primitive types. 030 * 031 * @author Niall Gallagher 032 */ 033@Retention(RetentionPolicy.RUNTIME) 034public @interface Version { 035 036 /** 037 * This represents the name of the XML attribute. Annotated fields 038 * or methods can optionally provide the name of the XML attribute 039 * they represent. If a name is not provided then the field or 040 * method name is used in its place. A name can be specified if 041 * the field or method name is not suitable for the XML attribute. 042 * 043 * @return the name of the XML attribute this represents 044 */ 045 String name() default ""; 046 047 /** 048 * This represents the revision of the class. A revision is used 049 * by the deserialization process to determine how to match the 050 * annotated fields and methods to the XML elements and attributes. 051 * If the version deserialized is different to the annotated 052 * revision then annotated fields and methods are not required 053 * and if there are excessive XML nodes they are ignored. 054 * 055 * @return this returns the version of the XML class schema 056 */ 057 double revision() default 1.0; 058 059 /** 060 * Determines whether the version is required within an XML 061 * element. Any field marked as not required will not have its 062 * value set when the object is deserialized. This is written 063 * only if the version is not the same as the default version. 064 * 065 * @return true if the version is required, false otherwise 066 */ 067 boolean required() default false; 068}