// for IgnoredItem
return 0;
}
private static int compare(String p1, String c1, String v1, String p2, String c2, String v2) {
AlphanumericComparator alphaNumComparator = new AlphanumericComparator();
// Compare packages
int result = alphaNumComparator.compare(p1, p2);
if (result != 0) {
return result;
}
// Same package, so compare classes
result = alphaNumComparator.compare(c1, c2);
if (result != 0) {
return result;
}
// Same robot, so compare versions
if (v1 == null && v2 == null) {
return 0;
}
if (v1 == null) {
return 1;
}
if (v2 == null) {
return -1;
}
if (v1.equals(v2)) {
return 0;
}
if (v1.indexOf(".") < 0 || v2.indexOf(".") < 0) {
return alphaNumComparator.compare(v1, v2);
}
// Dot separated versions.
StringTokenizer s1 = new StringTokenizer(v1, ".");
StringTokenizer s2 = new StringTokenizer(v2, ".");
while (s1.hasMoreTokens() && s2.hasMoreTokens()) {
String tok1 = s1.nextToken();
String tok2 = s2.nextToken();
try {
int i1 = Integer.parseInt(tok1);
int i2 = Integer.parseInt(tok2);
if (i1 != i2) {
return i1 - i2;
}
} catch (NumberFormatException e) {
int tc = alphaNumComparator.compare(tok1, tok2);
if (tc != 0) {
return tc;
}
}