Class VersionString
- java.lang.Object
-
- net.adoptopenjdk.icedteaweb.jnlp.version.VersionString
-
public class VersionString extends java.lang.ObjectA version-string is a list of version-ranges separated by spaces. A version-range is either a version-id, a version-id followed by a star (*), a version-id followed by a plus sign (+) , or two version-ranges combined using an ampersand (&). The star means prefix match, the plus sign means this version or greater, and the ampersand means the logical and-ing of the two version-ranges.The syntax of version-strings is:
version-string ::= version-range ( " " version-range) * version-range ::= simple-range ( "&" simple-range) * simple-range ::= version-id | version-id modifier modifier ::= "+" | "*"See JSR-56 Specification, Appendix A.
- See Also:
JNLPVersionPatterns
-
-
Field Summary
Fields Modifier and Type Field Description static VersionStringANY_VERSIONprivate VersionRange[]versionRanges
-
Constructor Summary
Constructors Modifier Constructor Description privateVersionString(VersionRange[] versionRanges)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) intcompare(VersionId versionId1, VersionId versionId2)Compares two version-ids in the context of this version-string.booleancontains(java.lang.String versionId)Checks if this version-string (list of exact version-ids or version ranges) contains the givenversionId.booleancontains(VersionId versionId)Checks if this version-string (list of exact version-ids or version ranges) contains the givenversionId.booleancontainsSingleVersionRange()booleanequals(java.lang.Object otherVersionString)static VersionStringfromString(java.lang.String versionString)Construct a version-string by the givenversionString.VersionIdgetExactVersion()private intindexOfFirstRangeContaining(VersionId versionId)booleanisExactVersion()java.lang.StringtoString()Provides string representation of this version-string.
-
-
-
Field Detail
-
ANY_VERSION
public static VersionString ANY_VERSION
-
versionRanges
private final VersionRange[] versionRanges
-
-
Constructor Detail
-
VersionString
private VersionString(VersionRange[] versionRanges)
-
-
Method Detail
-
fromString
public static VersionString fromString(java.lang.String versionString)
Construct a version-string by the givenversionString.- Parameters:
versionString- a version-string- Returns:
- a versionString
-
containsSingleVersionRange
public boolean containsSingleVersionRange()
- Returns:
trueif this version-string consists of only a single version-range,falseotherwise.
-
isExactVersion
public boolean isExactVersion()
- Returns:
trueif this version-string consists of a single version-range which is an exact match,falseotherwise.
-
getExactVersion
public VersionId getExactVersion()
- Returns:
- the exact version if this version-string is one
- Throws:
java.lang.IllegalStateException- if this version-string is not none
-
contains
public boolean contains(java.lang.String versionId)
Checks if this version-string (list of exact version-ids or version ranges) contains the givenversionId.- Parameters:
versionId- a version-id- Returns:
trueif this version-string contains the givenversionId,falseotherwise
-
contains
public boolean contains(VersionId versionId)
Checks if this version-string (list of exact version-ids or version ranges) contains the givenversionId.- Parameters:
versionId- a version-id- Returns:
trueif this version-string contains the givenversionId,falseotherwise
-
compare
int compare(VersionId versionId1, VersionId versionId2)
Compares two version-ids in the context of this version-string. This implementation follows the specification of aComparator.If two or more version-id match the given version-string, the JNLP Client should use the one matching the earlier version-range in the version-string.
If two or more version-id match a given version-range, the JNLP Client should use the one with the highest version-id.
See JSR-56 Specification, Appendix A.
- Parameters:
versionId1- a version-idversionId2- a version-id- Returns:
- a negative int if versionId1 is less than versionId2, a positive int if versionId1 is after than versionId2 or zero if they are equal.
-
indexOfFirstRangeContaining
private int indexOfFirstRangeContaining(VersionId versionId)
-
equals
public boolean equals(java.lang.Object otherVersionString)
- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()
Provides string representation of this version-string.- Overrides:
toStringin classjava.lang.Object- Returns:
- a string representation of this version-string
-
-