Class VersionString


  • public class VersionString
    extends java.lang.Object
    A 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
    • Constructor Detail

      • VersionString

        private VersionString​(VersionRange[] versionRanges)
    • Method Detail

      • fromString

        public static VersionString fromString​(java.lang.String versionString)
        Construct a version-string by the given versionString.
        Parameters:
        versionString - a version-string
        Returns:
        a versionString
      • containsSingleVersionRange

        public boolean containsSingleVersionRange()
        Returns:
        true if this version-string consists of only a single version-range, false otherwise.
      • isExactVersion

        public boolean isExactVersion()
        Returns:
        true if this version-string consists of a single version-range which is an exact match, false otherwise.
      • 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 given versionId.
        Parameters:
        versionId - a version-id
        Returns:
        true if this version-string contains the given versionId, false otherwise
      • contains

        public boolean contains​(VersionId versionId)
        Checks if this version-string (list of exact version-ids or version ranges) contains the given versionId.
        Parameters:
        versionId - a version-id
        Returns:
        true if this version-string contains the given versionId, false otherwise
      • compare

        int compare​(VersionId versionId1,
                    VersionId versionId2)
        Compares two version-ids in the context of this version-string. This implementation follows the specification of a Comparator.

        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-id
        versionId2 - 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:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Provides string representation of this version-string.
        Overrides:
        toString in class java.lang.Object
        Returns:
        a string representation of this version-string