From d1cf31f679edbcef152a4d69a52be0a5468e596f Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Fri, 2 May 2014 10:41:03 +0100 Subject: [PATCH] JAL-1369 JAL-1397 version check to support correct interpretation for older projects where data semantics have changed --- src/jalview/gui/Jalview2XML.java | 57 +++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/src/jalview/gui/Jalview2XML.java b/src/jalview/gui/Jalview2XML.java index da81945..400fd94 100644 --- a/src/jalview/gui/Jalview2XML.java +++ b/src/jalview/gui/Jalview2XML.java @@ -3178,7 +3178,62 @@ public class Jalview2XML // and finally return. return af; } - Vector newStructureViewers=null; + + /** + * + * @param supported - minimum version we are comparing against + * @param version - version of data being processsed. + * @return true if version is development/null or evaluates to the same or + * later X.Y.Z (where X,Y,Z are like [0-9]+b?[0-9]*) + */ + private boolean isVersionStringLaterThan(String supported, String version) + { + if (version == null || version.equalsIgnoreCase("DEVELOPMENT BUILD") + || version.equalsIgnoreCase("Test")) + { + System.err.println("Assuming project file with " + + (version == null ? "null" : version) + + " is compatible with Jalview version " + supported); + return true; + } + else + { + StringTokenizer currentV = new StringTokenizer(supported, "."), fileV = new StringTokenizer( + version, "."); + while (currentV.hasMoreTokens() && fileV.hasMoreTokens()) + { + // convert b to decimal to catch bugfix releases within a series + String curT = currentV.nextToken().toLowerCase().replace('b', '.'); + String fileT = fileV.nextToken().toLowerCase().replace('b', '.'); + try + { + if (Float.valueOf(curT) > Float.valueOf(fileT)) + { + // current version is newer than the version that wrote the file + return false; + } + } catch (NumberFormatException nfe) + { + System.err + .println("** WARNING: Version comparison failed for tokens (" + + curT + + ") and (" + + fileT + + ")\n** Current: '" + + supported + "' and Version: '" + version + "'"); + } + } + if (currentV.hasMoreElements()) + { + // fileV has no minor version but identical series to current + return false; + } + } + return true; + } + + Vector newStructureViewers = null; + protected void addNewStructureViewer(AppJmol sview) { if (newStructureViewers != null) -- 1.7.10.2