From 35ec8a700cccb47f2d9a0ced5d89085772cfaebd Mon Sep 17 00:00:00 2001 From: Arnaud Roques Date: Wed, 17 May 2023 21:34:24 +0200 Subject: [PATCH] chore: simply Version.java implementation --- .../sourceforge/plantuml/version/Version.java | 43 ++++++------------- 1 file changed, 13 insertions(+), 30 deletions(-) diff --git a/src/net/sourceforge/plantuml/version/Version.java b/src/net/sourceforge/plantuml/version/Version.java index a8478c449..4ed1260c8 100644 --- a/src/net/sourceforge/plantuml/version/Version.java +++ b/src/net/sourceforge/plantuml/version/Version.java @@ -39,55 +39,38 @@ import java.util.Date; import net.sourceforge.plantuml.log.Logme; import net.sourceforge.plantuml.security.SURL; +import net.sourceforge.plantuml.utils.SignatureUtils; public class Version { - // ::remove folder when __HAXE__ + // ::remove folder when __HAXE__ - private static final int MAJOR_SEPARATOR = 1000000; - - public static int version() { - return 1202307; - } - - public static int versionPatched() { - if (beta() != 0) { - return version() + 1; - } - return version(); - } + private static final String version = "1.2023.8beta2"; public static String versionString() { - if (beta() != 0) { - return dotted(version() + 1) + "beta" + beta(); - } - return dotted(version()); + return version; } public static String fullDescription() { return "PlantUML version " + Version.versionString() + " (" + Version.compileTimeString() + ")"; } - private static String dotted(int nb) { - final String minor = "" + nb % MAJOR_SEPARATOR; - final String major = "" + nb / MAJOR_SEPARATOR; - return major + "." + minor.substring(0, 4) + "." + Integer.parseInt(minor.substring(4)); - } - public static String versionString(int size) { final StringBuilder sb = new StringBuilder(versionString()); - while (sb.length() < size) { + while (sb.length() < size) sb.append(' '); - } + return sb.toString(); } public static int beta() { - final int beta = 2; - return beta; + final int x = version.indexOf("beta"); + if (x == -1) + return 0; + return Integer.parseInt(version.substring(x + "beta".length())); } public static String etag() { - return Integer.toString(version() % MAJOR_SEPARATOR - 201670, 36) + Integer.toString(beta(), 36); + return SignatureUtils.getMD5Hex(version); } public static String turningId() { @@ -99,9 +82,9 @@ public class Version { } public static String compileTimeString() { - if (beta() != 0) { + if (version.contains("beta")) return "Unknown compile time"; - } + return new Date(Version.compileTime()).toString(); }