|
|
|
@ -38,7 +38,7 @@ public class yacyVersion implements Comparator<yacyVersion>, Comparable<yacyVers
|
|
|
|
|
* i.e. yacy_v0.51_20070321_3501.tar.gz
|
|
|
|
|
* @param release
|
|
|
|
|
*/
|
|
|
|
|
public yacyVersion(String release, String host) {
|
|
|
|
|
public yacyVersion(String release, final String host) {
|
|
|
|
|
|
|
|
|
|
this.name = release;
|
|
|
|
|
if (release == null || !(release.endsWith(".tar.gz") || release.endsWith(".tar"))) {
|
|
|
|
@ -54,7 +54,7 @@ public class yacyVersion implements Comparator<yacyVersion>, Comparable<yacyVers
|
|
|
|
|
// now all release names have the form
|
|
|
|
|
// ${releaseVersion}_${DSTAMP}_${releaseNr}
|
|
|
|
|
final String[] comp = release.split("_"); // should be 3 parts
|
|
|
|
|
if (comp.length != 3) {
|
|
|
|
|
if (comp.length < 2 || comp.length > 3) {
|
|
|
|
|
throw new RuntimeException("release file name '" + release + "' is not valid, 3 information parts expected");
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
@ -62,17 +62,21 @@ public class yacyVersion implements Comparator<yacyVersion>, Comparable<yacyVers
|
|
|
|
|
} catch (final NumberFormatException e) {
|
|
|
|
|
throw new RuntimeException("release file name '" + release + "' is not valid, '" + comp[0] + "' should be a float number");
|
|
|
|
|
}
|
|
|
|
|
this.mainRelease = ((int) (this.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"));
|
|
|
|
|
this.dateStamp = comp[1];
|
|
|
|
|
if (this.getDateStamp().length() != 8) {
|
|
|
|
|
if (getDateStamp().length() != 8) {
|
|
|
|
|
throw new RuntimeException("release file name '" + release + "' is not valid, '" + comp[1] + "' should be a 8-digit date string");
|
|
|
|
|
}
|
|
|
|
|
if (comp.length > 2) {
|
|
|
|
|
try {
|
|
|
|
|
this.svn = Integer.parseInt(comp[2]);
|
|
|
|
|
} catch (final NumberFormatException e) {
|
|
|
|
|
throw new RuntimeException("release file name '" + release + "' is not valid, '" + comp[2] + "' should be a integer number");
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
this.svn = 0; // we migrate to git
|
|
|
|
|
}
|
|
|
|
|
// finished! we parsed a relase string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -105,19 +109,23 @@ public class yacyVersion implements Comparator<yacyVersion>, Comparable<yacyVers
|
|
|
|
|
* a ordered structure, like TreeSet or TreeMap
|
|
|
|
|
*/
|
|
|
|
|
public int compare(final yacyVersion v0, final yacyVersion v1) {
|
|
|
|
|
int r = (Float.valueOf(v0.getReleaseNr())).compareTo(Float.valueOf(v1.getReleaseNr()));
|
|
|
|
|
if (r != 0) return r;
|
|
|
|
|
r = v0.getDateStamp().compareTo(v1.getDateStamp());
|
|
|
|
|
if (r != 0) return r;
|
|
|
|
|
return (Integer.valueOf(v0.getSvn())).compareTo(Integer.valueOf(v1.getSvn()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean equals(final Object obj) {
|
|
|
|
|
if (obj instanceof yacyVersion) {
|
|
|
|
|
final yacyVersion v = (yacyVersion) obj;
|
|
|
|
|
return (this.getSvn() == v.getSvn()) && (this.getName().equals(v.getName()));
|
|
|
|
|
return (getReleaseNr() == v.getReleaseNr()) && (getSvn() == v.getSvn()) && (getName().equals(v.getName()));
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int hashCode() {
|
|
|
|
|
return this.getName().hashCode();
|
|
|
|
|
return getName().hashCode();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -169,7 +177,7 @@ public class yacyVersion implements Comparator<yacyVersion>, Comparable<yacyVers
|
|
|
|
|
* @return timestamp
|
|
|
|
|
*/
|
|
|
|
|
public String getDateStamp() {
|
|
|
|
|
return dateStamp;
|
|
|
|
|
return this.dateStamp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -177,7 +185,7 @@ public class yacyVersion implements Comparator<yacyVersion>, Comparable<yacyVers
|
|
|
|
|
* @return svn revision as integer
|
|
|
|
|
*/
|
|
|
|
|
public int getSvn() {
|
|
|
|
|
return svn;
|
|
|
|
|
return this.svn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -185,7 +193,7 @@ public class yacyVersion implements Comparator<yacyVersion>, Comparable<yacyVers
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public boolean isMainRelease() {
|
|
|
|
|
return mainRelease;
|
|
|
|
|
return this.mainRelease;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -193,12 +201,22 @@ public class yacyVersion implements Comparator<yacyVersion>, Comparable<yacyVers
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public float getReleaseNr() {
|
|
|
|
|
return releaseNr;
|
|
|
|
|
return this.releaseNr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String getName() {
|
|
|
|
|
return name;
|
|
|
|
|
return this.name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void main(final String[] args) {
|
|
|
|
|
final yacyVersion y1 = new yacyVersion("yacy_v0.51_20070321_3501.tar.gz", null);
|
|
|
|
|
final yacyVersion y2 = new yacyVersion("yacy_v1.0_20111203_8134.tar.gz", null);
|
|
|
|
|
final yacyVersion y3 = new yacyVersion("yacy_v1.01_20111206_8140.tar.gz", null);
|
|
|
|
|
final yacyVersion y4 = new yacyVersion("yacy_v1.01_20111207.tar.gz", null);
|
|
|
|
|
System.out.println(y1.compareTo(y2));
|
|
|
|
|
System.out.println(y2.compareTo(y3));
|
|
|
|
|
System.out.println(y3.compareTo(y4));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|