X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FJalview2XML.java;h=a3604d67c0b93dcc3ee618dde69e563f4584ceb2;hb=c7633fc4fc9799d9a906c8b60b3e3981a2c0b4fb;hp=24b6e7801f375c9d63fbf0bdf47d37f2084a0c80;hpb=ecb334f98fca8ed9f27b6a7d027dea3bd4213023;p=jalview.git diff --git a/src/jalview/gui/Jalview2XML.java b/src/jalview/gui/Jalview2XML.java index 24b6e78..a3604d6 100644 --- a/src/jalview/gui/Jalview2XML.java +++ b/src/jalview/gui/Jalview2XML.java @@ -79,6 +79,7 @@ import jalview.structure.StructureSelectionManager; import jalview.structures.models.AAStructureBindingModel; import jalview.util.MessageManager; import jalview.util.Platform; +import jalview.util.StringUtils; import jalview.util.jarInputStreamProvider; import jalview.viewmodel.AlignmentViewport; import jalview.viewmodel.seqfeatures.FeatureRendererSettings; @@ -117,7 +118,6 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; -import java.util.StringTokenizer; import java.util.Vector; import java.util.jar.JarEntry; import java.util.jar.JarInputStream; @@ -4021,18 +4021,22 @@ public class Jalview2XML } /** + * Answers true if 'version' is equal to or later than 'supported', where each + * is formatted as major/minor versions like "2.8.3" or "2.3.4b1" for bugfix + * changes. Development and test values for 'version' are leniently treated + * i.e. answer true. * * @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]*) + * - version of data being processsed + * @return */ public static boolean isVersionStringLaterThan(String supported, String version) { - if (version == null || version.equalsIgnoreCase("DEVELOPMENT BUILD") + if (supported == null || version == null + || version.equalsIgnoreCase("DEVELOPMENT BUILD") || version.equalsIgnoreCase("Test") || version.equalsIgnoreCase("AUTOMATED BUILD")) { @@ -4043,45 +4047,8 @@ public class Jalview2XML } 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 - { - float supportedVersionToken = Float.parseFloat(curT); - float myVersiontoken = Float.parseFloat(fileT); - if (supportedVersionToken > myVersiontoken) - { - // current version is newer than the version that wrote the file - return false; - } - if (supportedVersionToken < myVersiontoken) - { - // current version is older than the version that wrote the file - return true; - } - } 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 StringUtils.compareVersions(version, supported, "b") >= 0; } - return true; } Vector newStructureViewers = null;