2 * This file is part of the Vamsas Client version 0.2.
\r
3 * Copyright 2010 by Jim Procter, Iain Milne, Pierre Marguerite,
\r
4 * Andrew Waterhouse and Dominik Lindner.
\r
6 * Earlier versions have also been incorporated into Jalview version 2.4
\r
7 * since 2008, and TOPALi version 2 since 2007.
\r
9 * The Vamsas Client is free software: you can redistribute it and/or modify
\r
10 * it under the terms of the GNU Lesser General Public License as published by
\r
11 * the Free Software Foundation, either version 3 of the License, or
\r
12 * (at your option) any later version.
\r
14 * The Vamsas Client is distributed in the hope that it will be useful,
\r
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
17 * GNU Lesser General Public License for more details.
\r
19 * You should have received a copy of the GNU Lesser General Public License
\r
20 * along with the Vamsas Client. If not, see <http://www.gnu.org/licenses/>.
\r
22 package uk.ac.vamsas.objects.utils.document;
\r
24 import java.util.Hashtable;
\r
27 * enumerates versions for the VamsasDocument.Version string provides version
\r
28 * comparison methods TODO: LATER: associate schema versions with these strings
\r
30 public class VersionEntries {
\r
31 public static final String ALPHA_VERSION = "alpha";
\r
33 public static final String BETA_VERSION = "beta";
\r
35 protected static Hashtable versions;
\r
37 versions = new Hashtable();
\r
38 // integers represent version hierarchy - 0 precedes 1
\r
39 versions.put(ALPHA_VERSION, new Integer(0));
\r
40 versions.put(BETA_VERSION, new Integer(1));
\r
43 // TODO: LATER: decide on best pattern for enumeration classes (ie - need an
\r
44 // ordered list of versions, and validator, plus explicit enum-strings)
\r
45 public static boolean isVersion(String vstring) {
\r
46 return versions.containsKey(vstring);
\r
50 * returns 0 if levels are equivalent, 1 if higher is valid and higher, 2 if
\r
51 * lower is valid and higher -1 if both levels are invalid
\r
57 public static int compare(String higher, String lower) {
\r
58 int v_1 = versions.containsKey(higher) ? ((Integer) versions.get(higher))
\r
60 int v_2 = versions.containsKey(lower) ? ((Integer) versions.get(lower))
\r
62 int comp = v_1 < v_2 ? 2 : v_1 == v_2 ? 0 : 1;
\r
63 return (comp == 0) ? (v_1 != -1 ? 0 : -1) : comp;
\r
67 * @return the latest version that this vamsas library supports
\r
69 public static String latestVersion() {
\r
70 return BETA_VERSION;
\r