4 package org.vamsas.objects.utils.document;
6 import java.util.Hashtable;
9 * enumerates versions for the VamsasDocument.Version string
10 * provides version comparison methods
11 * TODO: LATER: associate schema versions with these strings
13 public class VersionEntries {
14 public static final String ALPHA_VERSION="alpha";
15 public static final String BETA_VERSION="beta";
16 protected static Hashtable versions;
18 versions = new Hashtable();
19 // integers represent version hierarchy - 0 precedes 1
20 versions.put(ALPHA_VERSION, new Integer(0));
21 versions.put(BETA_VERSION, new Integer(1));
23 // TODO: LATER: decide on best pattern for enumeration classes (ie - need an ordered list of versions, and validator, plus explicit enum-strings)
24 public static boolean isVersion(String vstring) {
25 return versions.containsKey(vstring);
28 * returns 0 if levels are equivalent,
29 * 1 if higher is valid and higher,
30 * 2 if lower is valid and higher
31 * -1 if both levels are invalid
36 public static int compare(String higher, String lower) {
37 int v_1 = versions.containsKey(higher) ? ((Integer) versions.get(higher)).intValue() : -1;
38 int v_2 = versions.containsKey(lower) ? ((Integer) versions.get(lower)).intValue() : -1;
39 int comp = v_1<v_2 ? 2 : v_1 == v_2 ? 0 : 1;
40 return (comp==0) ? (v_1!=-1 ? 0 : -1) : comp;
43 * @return the latest version that this vamsas library supports
45 public static String latestVersion() {