Class VersionId
java.lang.Object
net.adoptopenjdk.icedteaweb.jnlp.version.VersionId
- All Implemented Interfaces:
Comparable<VersionId>
A version-id specifies the version that is associated with a resource, such as a JAR file.
The version-id used in this specification must conform to the following syntax:
version-id ::= string ( separator string ) *
string ::= char ( char ) *
char ::= any ASCII character except a space, an ampersand, a separator, or a modifier.
separator ::= "." | "-" | "_"
modifier ::= "+" | "*"
See JSR-56 Specification, Appendix A.
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) String[]asNormalizedTuple(int normalizationLength) Normalizes a tuple to compare two version-ids.(package private) String[]asTuple()NOTE: Package visible for testing - do not use this method outside of VersionId.intbooleanstatic VersionIdfromString(String versionId) Construct a version-id by the givenversionId.(package private) booleanCompares whether this version-id is equal to theotherVersionId.(package private) booleanisLessThan(VersionId otherVersionId) Compares whether this version-id is less thanotherVersionId.(package private) booleanisPrefixMatchOf(VersionId otherVersionId) A is a prefix matches of B if, when represented as tuples, the elements of A are the same as the first elements of B.private static ObjectprepareForComparison(String tupleValue) This method provides a tuple value as correct object (numeric or alphanumeric) for normalized comparison.toString()Provides a string representation of thisVersionId.
-
Field Details
-
ZERO_ELEMENT
- See Also:
-
versionId
-
tuple
A version-id can be described as a tuple of values. A version-id string is broken in parts for each separator ('.', '-', or '_'). For example, "1.3.0-rc2-w" becomes (1,3,0,rc2,w), and "1.2.2-001" becomes (1,2,2,001).
-
-
Constructor Details
-
VersionId
-
-
Method Details
-
fromString
-
asVersionString
-
toString
-
isEqualTo
Compares whether this version-id is equal to theotherVersionId.- Parameters:
otherVersionId- a version-id- Returns:
trueif this equals tootherVersionId,falseotherwise.
-
equals
-
compareTo
- Specified by:
compareToin interfaceComparable<VersionId>
-
isPrefixMatchOf
A is a prefix matches of B if, when represented as tuples, the elements of A are the same as the first elements of B. The padding with 0 (zero element) entries ensures that B has at least as many elements as A. For example, given the above definition "1.2.1" will be a prefix matches to "1.2.1-004", but not to "1.2.0" or "1.2.10". The padding step ensures that "1.2.0.0" is a prefix of "1.2". Note that prefix matching and ordering are distinct: "1.3" is greater than "1.2", and less than "1.4", but not a prefix of either. See JSR-56 Specification, Appendix A.2 Prefix Match.- Parameters:
otherVersionId- a version-id- Returns:
trueif this version-id is a prefix matches ofotherVersionId,falseotherwise.
-
isLessThan
Compares whether this version-id is less thanotherVersionId. A is less than B if, when represented as normalized tuples, there exists some element of A which is less than the corresponding element of B, and all earlier elements of A are the same as in B (see JSR-56 Specification, Appendix A.1 Ordering). Two numeric elements are compared numerically. Two alphanumeric elements are compared lexicographically according to the Unicode value of the individual characters. When one element is numeric and the other is alphanumeric, the alphanumeric element is greater than the numeric element. Numeric elements have lower precedence than non-numeric elements. See JSR-56 Specification, Appendix A- Parameters:
otherVersionId- a version-id- Returns:
trueif this version-id is less thanotherVersionId,falseotherwise.
-
asNormalizedTuple
Normalizes a tuple to compare two version-ids. The tuple is padded with 0 (zero element) entries at the end. For example, to compare the tuples T1(1, 4) and T2(1, 4, 1) you need to normalize T2 to (1, 4, 0) first.NOTE: Package visible for testing - do not use this method outside of VersionId.
- Parameters:
normalizationLength- the tuple length to normalize to- Returns:
- the normalized tuple
-
prepareForComparison
This method provides a tuple value as correct object (numeric or alphanumeric) for normalized comparison. Each element in a tuple is either numeric or alphanumeric. An elements is numeric if it can be parsed as Java int, otherwise it is alphanumeric. Two numeric elements are compared numerically. Two alphanumeric elements are compared lexicographically according to the Unicode value of the individual characters. When one element is numeric and the other is alphanumeric, the alphanumeric element is greater than the numeric element. Numeric elements have lower precedence than non-numeric elements. See JSR-56 Specification, Appendix A- Parameters:
tupleValue- the raw tuple value- Returns:
- the tuple value suited for normalized comparison
-
asTuple
String[] asTuple()NOTE: Package visible for testing - do not use this method outside of VersionId.
-