KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > speedo > metadata > SpeedoVersion


1 /**
2  * Speedo: an implementation of JDO compliant personality on top of JORM generic
3  * I/O sub-system.
4  * Copyright (C) 2001-2004 France Telecom R&D
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  *
21  *
22  * Contact: speedo@objectweb.org
23  *
24  * Authors: S.Chassande-Barrioz.
25  *
26  */

27
28 package org.objectweb.speedo.metadata;
29
30 /**
31  * This class corresponds to the description of the attribute version
32  * in the XML file.
33  * @author Y.Bersihand
34  */

35 public class SpeedoVersion {
36     
37     public final static byte VERSION_NUMBER = 3;
38     public final static byte STATE_COMPARISON = 2;
39     public final static byte DATE_TIME = 1;
40     public final static byte NO_VERSION = 0;
41     
42     /**
43      * Description of the class containing the version
44      */

45     public SpeedoClass jdoClass;
46
47     /**
48      * The strategy followed
49      */

50     public byte strategy = NO_VERSION;
51     
52     /**
53      * Transforms a String into a Byte. The String must corresponds to local variables.
54      * It returns the byte associated with the variable.
55      * @param s String to transform.
56      * @return the byte associated to the String.
57      */

58     public static byte toByte(String JavaDoc s) {
59         if (s.equalsIgnoreCase("version-number"))
60             return VERSION_NUMBER;
61         else if (s.equalsIgnoreCase("state-comparison"))
62             return STATE_COMPARISON;
63         else if (s.equalsIgnoreCase("date-time"))
64                    return DATE_TIME;
65         else
66             return NO_VERSION;
67     }
68     
69     /**
70      * Transforms a byte into a String.
71      * @param b the byte to transform.
72      * @return the String associated to the byte.
73      */

74     public static String JavaDoc toString(byte b) {
75        if (b == VERSION_NUMBER)
76            return "versionnumber";
77        else if (b == STATE_COMPARISON)
78            return "statecomparison";
79        else if (b == DATE_TIME)
80                   return "datetime";
81        else
82            return "no-version";
83     }
84 }
85
Popular Tags