org.apache.maven.archiva.common.utils
Class VersionComparator
java.lang.Object
org.apache.maven.archiva.common.utils.VersionComparator
- All Implemented Interfaces:
- java.util.Comparator<java.lang.String>
public class VersionComparator
- extends java.lang.Object
- implements java.util.Comparator<java.lang.String>
VersionComparator - compare the parts of two version strings.
Technique.
* Split the version strings into parts by splitting on "-._" first, then breaking apart words from numbers.
"1.0" = "1", "0"
"1.0-alpha-1" = "1", "0", "alpha", "1"
"2.0-rc2" = "2", "0", "rc", "2"
"1.3-m2" = "1", "3", "m", "3"
compare each part individually, and when they do not match, perform the following test.
Numbers are calculated per normal comparison rules.
Words that are part of the "special word list" will be treated as their index within that heirarchy.
Words that cannot be identified as special, are treated using normal case-insensitive comparison rules.
|
Method Summary |
int |
compare(java.lang.String o1,
java.lang.String o2)
|
static java.util.Comparator<java.lang.String> |
getInstance()
|
static java.lang.String[] |
toParts(java.lang.String version)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface java.util.Comparator |
equals |
VersionComparator
public VersionComparator()
getInstance
public static java.util.Comparator<java.lang.String> getInstance()
compare
public int compare(java.lang.String o1,
java.lang.String o2)
- Specified by:
compare in interface java.util.Comparator<java.lang.String>
toParts
public static java.lang.String[] toParts(java.lang.String version)