using double instead float for a better release ordering

pull/1/head
Michael Peter Christen 13 years ago
parent 43c2c6e588
commit 0f82fb3628

@ -143,7 +143,7 @@ public final class yacyRelease extends yacyVersion {
// return a dev-release or a main-release // return a dev-release or a main-release
if ((latestdev != null) && if ((latestdev != null) &&
((latestmain == null) || (latestdev.compareTo(latestmain) > 0)) && ((latestmain == null) || (latestdev.compareTo(latestmain) > 0)) &&
(!(Float.toString(latestdev.getReleaseNr()).matches(blacklist)))) { (!(Double.toString(latestdev.getReleaseNr()).matches(blacklist)))) {
// consider a dev-release // consider a dev-release
if (latestdev.compareTo(thisVersion()) <= 0) { if (latestdev.compareTo(thisVersion()) <= 0) {
Network.log.logInfo( Network.log.logInfo(
@ -155,7 +155,7 @@ public final class yacyRelease extends yacyVersion {
} }
if (latestmain != null) { if (latestmain != null) {
// consider a main release // consider a main release
if ((Float.toString(latestmain.getReleaseNr()).matches(blacklist))) { if ((Double.toString(latestmain.getReleaseNr()).matches(blacklist))) {
Network.log.logInfo( Network.log.logInfo(
"rulebasedUpdateInfo: latest dev " + (latestdev == null ? "null" : latestdev.getName()) + "rulebasedUpdateInfo: latest dev " + (latestdev == null ? "null" : latestdev.getName()) +
" matches with blacklist '" + blacklist + "'"); " matches with blacklist '" + blacklist + "'");
@ -172,7 +172,7 @@ public final class yacyRelease extends yacyVersion {
} }
if ((concept.equals("main")) && (latestmain != null)) { if ((concept.equals("main")) && (latestmain != null)) {
// return a main-release // return a main-release
if ((Float.toString(latestmain.getReleaseNr()).matches(blacklist))) { if ((Double.toString(latestmain.getReleaseNr()).matches(blacklist))) {
Network.log.logInfo( Network.log.logInfo(
"rulebasedUpdateInfo: latest main " + latestmain.getName() + "rulebasedUpdateInfo: latest main " + latestmain.getName() +
" matches with blacklist'" + blacklist + "'"); " matches with blacklist'" + blacklist + "'");

@ -21,7 +21,7 @@ public class yacyVersion implements Comparator<yacyVersion>, Comparable<yacyVers
* this value is overwritten when a peer with later version appears*/ * this value is overwritten when a peer with later version appears*/
public static double latestRelease = 0.1; // public static double latestRelease = 0.1; //
private float releaseNr; private double releaseNr;
private final String dateStamp; private final String dateStamp;
private int svn; private int svn;
private final boolean mainRelease; private final boolean mainRelease;
@ -58,9 +58,9 @@ public class yacyVersion implements Comparator<yacyVersion>, Comparable<yacyVers
throw new RuntimeException("release file name '" + release + "' is not valid, 3 information parts expected"); throw new RuntimeException("release file name '" + release + "' is not valid, 3 information parts expected");
} }
try { try {
this.releaseNr = Float.parseFloat(comp[0]); this.releaseNr = Double.parseDouble(comp[0]);
} catch (final NumberFormatException e) { } catch (final NumberFormatException e) {
throw new RuntimeException("release file name '" + release + "' is not valid, '" + comp[0] + "' should be a float number"); throw new RuntimeException("release file name '" + release + "' is not valid, '" + comp[0] + "' should be a double number");
} }
this.mainRelease = ((int) (getReleaseNr() * 100)) % 10 == 0 || (host != null && host.endsWith("yacy.net")); this.mainRelease = ((int) (getReleaseNr() * 100)) % 10 == 0 || (host != null && host.endsWith("yacy.net"));
//System.out.println("Release version " + this.releaseNr + " is " + ((this.mainRelease) ? "main" : "std")); //System.out.println("Release version " + this.releaseNr + " is " + ((this.mainRelease) ? "main" : "std"));
@ -111,7 +111,7 @@ public class yacyVersion implements Comparator<yacyVersion>, Comparable<yacyVers
*/ */
@Override @Override
public int compare(final yacyVersion v0, final yacyVersion v1) { public int compare(final yacyVersion v0, final yacyVersion v1) {
int r = (Float.valueOf(v0.getReleaseNr())).compareTo(Float.valueOf(v1.getReleaseNr())); int r = (Double.valueOf(v0.getReleaseGitNr())).compareTo(Double.valueOf(v1.getReleaseGitNr()));
if (r != 0) return r; if (r != 0) return r;
r = v0.getDateStamp().compareTo(v1.getDateStamp()); r = v0.getDateStamp().compareTo(v1.getDateStamp());
if (r != 0) return r; if (r != 0) return r;
@ -122,7 +122,7 @@ public class yacyVersion implements Comparator<yacyVersion>, Comparable<yacyVers
public boolean equals(final Object obj) { public boolean equals(final Object obj) {
if (obj instanceof yacyVersion) { if (obj instanceof yacyVersion) {
final yacyVersion v = (yacyVersion) obj; final yacyVersion v = (yacyVersion) obj;
return (getReleaseNr() == v.getReleaseNr()) && (getSvn() == v.getSvn()) && (getName().equals(v.getName())); return (getReleaseGitNr() == v.getReleaseGitNr()) && (getSvn() == v.getSvn()) && (getName().equals(v.getName()));
} }
return false; return false;
} }
@ -152,7 +152,7 @@ public class yacyVersion implements Comparator<yacyVersion>, Comparable<yacyVers
return new String[]{"dev", "0000"}; return new String[]{"dev", "0000"};
} }
final String mainversion = (Float.parseFloat(matcher.group(1)) < 0.11 ? "dev" : matcher.group(1)); final String mainversion = (Double.parseDouble(matcher.group(1)) < 0.11 ? "dev" : matcher.group(1));
String revision = matcher.group(2); String revision = matcher.group(2);
for(int i=revision.length();i<5;++i) revision += "0"; for(int i=revision.length();i<5;++i) revision += "0";
return new String[]{mainversion, revision}; return new String[]{mainversion, revision};
@ -201,13 +201,17 @@ public class yacyVersion implements Comparator<yacyVersion>, Comparable<yacyVers
} }
/** /**
* release number as float (e. g. 7.04) * release number as Double (e. g. 7.04)
* @return * @return
*/ */
public float getReleaseNr() { public double getReleaseNr() {
return this.releaseNr; return this.releaseNr;
} }
public double getReleaseGitNr() {
// combine release number with git number
return this.getReleaseNr() + ((getSvn()) / 10000000.0d);
}
public String getName() { public String getName() {
return this.name; return this.name;

Loading…
Cancel
Save