01: /**
02: * Speedo: an implementation of JDO compliant personality on top of JORM generic
03: * I/O sub-system.
04: * Copyright (C) 2001-2004 France Telecom R&D
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * 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: */package org.objectweb.speedo.metadata;
27:
28: /**
29: * This class corresponds to the description of the attribute version
30: * in the XML file.
31: * @author Y.Bersihand
32: */
33: public class SpeedoVersion {
34:
35: public final static byte VERSION_NUMBER = 3;
36: public final static byte STATE_COMPARISON = 2;
37: /**
38: * Versioning strategy based on the date
39: */
40: public final static byte DATE_TIME = 1;
41: public final static byte NO_VERSION = 0;
42:
43: /**
44: * The strategy followed
45: */
46: public byte strategy = NO_VERSION;
47:
48: /**
49: * Transforms a String into a Byte. The String must corresponds to local variables.
50: * It returns the byte associated with the variable.
51: * @param s String to transform.
52: * @return the byte associated to the String.
53: */
54: public static byte toByte(String s) {
55: if (s.equalsIgnoreCase("version-number"))
56: return VERSION_NUMBER;
57: else if (s.equalsIgnoreCase("state-comparison"))
58: return STATE_COMPARISON;
59: else if (s.equalsIgnoreCase("date-time"))
60: return DATE_TIME;
61: else
62: return NO_VERSION;
63: }
64:
65: /**
66: * Transforms a byte into a String.
67: * @param b the byte to transform.
68: * @return the String associated to the byte.
69: */
70: public static String toString(byte b) {
71: if (b == VERSION_NUMBER)
72: return "versionnumber";
73: else if (b == STATE_COMPARISON)
74: return "statecomparison";
75: else if (b == DATE_TIME)
76: return "datetime";
77: else
78: return "no-version";
79: }
80: }
|