public final class VersionNumber extends java.lang.Object implements java.lang.Comparable, StringConversion
VersionNumber has methods that can compare one instance
VersionNumber to another. During comparison,
VersionNumber attempts to interpret the parts of the
version string as numbers; if two corresponding parts cannot be
compared as numbers, they are compared lexicographically.
Whether or not two
VersionNumber instances have the
same number of parts, comparisons occur in a left-to-right
manner, part by part. As soon as a difference is detected, then
it can be determined which version number is earlier or later.
Comparableso that collections of
VersionNumbercan be easily sorted.
|Constructor and Description|
This creates an instance of
|Modifier and Type||Method and Description|
Returns the number of dot-separated fields contained in the version.
Compares this instance of
Returns the part of the version string requested or
This is a convenience method that simply calls
Compares the parts of the this
public VersionNumber(java.lang.String versionString)
VersionNumberbased on the dot-separated version string that is passed in.
public int countParts()
2. If the version string is "3", then this method returns
public java.lang.String getPart(int offset)
nullif the offset is out of bounds.
public final boolean isAfter(VersionNumber version)
trueif this VersionNumber is after the specified VersionNumber. Returns
falseif this VersionNumber is equal to or before the specified VersionNumber.
public final boolean isAfter(VersionNumber version, boolean orEquals)
public final boolean isBefore(VersionNumber version)
trueif this VersionNumber is before the specified VersionNumber. Returns
falseif this VersionNumber is equal to or after the specified VersionNumber.
public boolean isBefore(VersionNumber version, boolean orEquals)
VersionNumberwith the parts of the specified
VersionNumberto determine whether this
VersionNumberrepresents a version that comes before the specified version. Parts are compared one at a time, and the result is returned as soon as it is determined. For each comparison, an attempt is first made to convert both version parts to an
Integer.parseInt(). If this succeeds, then the version parts are compared numerically. If the conversion to
intfails because of a
NumberFormatException, the version parts are compared lexicographically using
String.compareTo(...). These steps are followed for each version part, so it may be the case that some parts are compared numerically and others lexicographically.
VersionNumber instance has extra zeros at
the end, while the one it is being compared to does not have extra
zeros, then the
VersionNumber with the extra zeros
is considered to be later than the
without the extra zeros.
public int compareTo(java.lang.Object o)
public boolean equals(java.lang.Object o)
VersionNumberwith the specified
trueif the version represented are identical.
public int hashCode()
public java.lang.String toString()
VersionNumberin dot-separated notation as a