net.sourceforge.jnlp
public class Version extends java.lang.Object
Version strings are divided by "._-" charecters into parts. These parts are compared numerically if they can be parsed as integers or lexographically as strings otherwise. If the number of parts is different between two version strings then the smaller one is padded with zero or the empty string. Note that the padding in this version means that 1.2+ matches 1.4.0-beta1, but may not in future versions.
Constructor and Description |
---|
Version(java.lang.String versions)
Create a Version object based on a version string (ie,
"1.2.3+ 4.56*").
|
Modifier and Type | Method and Description |
---|---|
protected int |
compare(java.lang.String part1,
java.lang.String part2)
Compares two parts of a version string, by value if both can
be interpreted as integers or lexically otherwise.
|
protected boolean |
equal(java.util.List<java.lang.String> parts1,
java.util.List<java.lang.String> parts2)
Returns whether the parts of one version are equal to the
parts of another version.
|
protected java.util.List<java.lang.String> |
getParts(java.lang.String oneVersion)
Return the constituent parts of a version string.
|
protected java.util.List<java.lang.String> |
getVersionStrings()
Return the individual version strings that make up a Version.
|
protected boolean |
greater(java.util.List<java.lang.String> parts1,
java.util.List<java.lang.String> parts2)
Returns whether the parts of one version are greater than
the parts of another version.
|
boolean |
isVersionId()
Returns true if the version represents a version-id (a
single version number such as 1.2) and false otherwise.
|
boolean |
matches(java.lang.String version)
Returns true if all of this version's version-ids match one
or more of the specifed version's version-id.
|
boolean |
matches(Version version)
Returns true if all of this version's version-ids match one
or more of the specifed version's version-id.
|
boolean |
matchesAny(java.lang.String version)
Returns true if any of this version's version-ids match one
or more of the specifed version's version-id.
|
boolean |
matchesAny(Version version)
Returns true if any of this version's version-ids match one
or more of the specifed version's version-id.
|
protected void |
normalize(java.util.List<java.util.List<java.lang.String>> versions,
int maxLength)
Normalize version strings so that they contain the same
number of constituent parts.
|
java.lang.String |
toString() |
public Version(java.lang.String versions)
public boolean isVersionId()
public boolean matches(java.lang.String version)
version
- a version stringpublic boolean matches(Version version)
version
- a Version objectpublic boolean matchesAny(java.lang.String version)
version
- a version stringpublic boolean matchesAny(Version version)
version
- a Version objectprotected boolean equal(java.util.List<java.lang.String> parts1, java.util.List<java.lang.String> parts2)
parts1
- normalized version partsparts2
- normalized version partsprotected boolean greater(java.util.List<java.lang.String> parts1, java.util.List<java.lang.String> parts2)
parts1
- normalized version partsparts2
- normalized version partsprotected int compare(java.lang.String part1, java.lang.String part2)
part1
- a part of a version stringpart2
- a part of a version stringprotected void normalize(java.util.List<java.util.List<java.lang.String>> versions, int maxLength)
versions
- list array of parts of a version stringmaxLength
- truncate lists to this maximum lengthprotected java.util.List<java.lang.String> getVersionStrings()
protected java.util.List<java.lang.String> getParts(java.lang.String oneVersion)
oneVersion
- a single version id string (not compound)public java.lang.String toString()
toString
in class java.lang.Object