1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-12-22 02:49:06 +00:00

chore: simply Version.java implementation

This commit is contained in:
Arnaud Roques 2023-05-17 21:34:24 +02:00
parent eb85d9c9c5
commit 35ec8a700c

View File

@ -39,55 +39,38 @@ import java.util.Date;
import net.sourceforge.plantuml.log.Logme; import net.sourceforge.plantuml.log.Logme;
import net.sourceforge.plantuml.security.SURL; import net.sourceforge.plantuml.security.SURL;
import net.sourceforge.plantuml.utils.SignatureUtils;
public class Version { public class Version {
// ::remove folder when __HAXE__ // ::remove folder when __HAXE__
private static final int MAJOR_SEPARATOR = 1000000; private static final String version = "1.2023.8beta2";
public static int version() {
return 1202307;
}
public static int versionPatched() {
if (beta() != 0) {
return version() + 1;
}
return version();
}
public static String versionString() { public static String versionString() {
if (beta() != 0) { return version;
return dotted(version() + 1) + "beta" + beta();
}
return dotted(version());
} }
public static String fullDescription() { public static String fullDescription() {
return "PlantUML version " + Version.versionString() + " (" + Version.compileTimeString() + ")"; 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) { public static String versionString(int size) {
final StringBuilder sb = new StringBuilder(versionString()); final StringBuilder sb = new StringBuilder(versionString());
while (sb.length() < size) { while (sb.length() < size)
sb.append(' '); sb.append(' ');
}
return sb.toString(); return sb.toString();
} }
public static int beta() { public static int beta() {
final int beta = 2; final int x = version.indexOf("beta");
return beta; if (x == -1)
return 0;
return Integer.parseInt(version.substring(x + "beta".length()));
} }
public static String etag() { public static String etag() {
return Integer.toString(version() % MAJOR_SEPARATOR - 201670, 36) + Integer.toString(beta(), 36); return SignatureUtils.getMD5Hex(version);
} }
public static String turningId() { public static String turningId() {
@ -99,9 +82,9 @@ public class Version {
} }
public static String compileTimeString() { public static String compileTimeString() {
if (beta() != 0) { if (version.contains("beta"))
return "Unknown compile time"; return "Unknown compile time";
}
return new Date(Version.compileTime()).toString(); return new Date(Version.compileTime()).toString();
} }