File: Version.java

package info (click to toggle)
simple-xml 2.7.1-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 8,524 kB
  • sloc: java: 45,356; xml: 277; sh: 11; makefile: 10
file content (68 lines) | stat: -rw-r--r-- 2,586 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
 * Version.java July 2008
 *
 * Copyright (C) 2008, Niall Gallagher <niallg@users.sf.net>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 
 * implied. See the License for the specific language governing 
 * permissions and limitations under the License.
 */

package org.simpleframework.xml;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/**
 * The <code>Version</code> annotation is used to specify an attribute
 * that is used to represent a revision of the class XML schema. This
 * annotation can annotate only floating point types such as double, 
 * float, and the java primitive object types. This can not be used to
 * annotate strings, enumerations or other primitive types.
 * 
 * @author Niall Gallagher
 */
@Retention(RetentionPolicy.RUNTIME)
public @interface Version {
   
   /**
    * This represents the name of the XML attribute. Annotated fields
    * or methods can optionally provide the name of the XML attribute
    * they represent. If a name is not provided then the field or 
    * method name is used in its place. A name can be specified if 
    * the field or method name is not suitable for the XML attribute.
    * 
    * @return the name of the XML attribute this represents
    */
   String name() default "";

   /**
    * This represents the revision of the class. A revision is used
    * by the deserialization process to determine how to match the
    * annotated fields and methods to the XML elements and attributes.
    * If the version deserialized is different to the annotated 
    * revision then annotated fields and methods are not required 
    * and if there are excessive XML nodes they are ignored.
    * 
    * @return this returns the version of the XML class schema
    */
   double revision() default 1.0;
   
   /**
    * Determines whether the version is required within an XML
    * element. Any field marked as not required will not have its
    * value set when the object is deserialized. This is written
    * only if the version is not the same as the default version.
    * 
    * @return true if the version is required, false otherwise
    */
   boolean required() default false;
}