Class VersionRange

java.lang.Object
net.adoptopenjdk.icedteaweb.jnlp.version.VersionRange

public class VersionRange extends Object
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 ( " " element) *
     version-range      ::=  simple-range ( "&" simple-range) *
     simple-range       ::=  version-id | version-id modifier
     modifier           ::=  "+" | "*"

See JSR-56 Specification, Appendix A.

See Also:
  • Field Details

    • simpleRanges

      private final SimpleRange[] simpleRanges
  • Constructor Details

    • VersionRange

      private VersionRange(SimpleRange[] simpleRanges)
  • Method Details

    • isCompoundVersion

      boolean isCompoundVersion()
      Returns:
      true if this version-range is a compound range using an ampersand (&), false otherwise
    • isExactVersion

      boolean isExactVersion()
      Checks whether this version-range represents a plain (exact) version without any postfix modifiers.
      Returns:
      true if this version-range does not have any modifiers, false otherwise.
    • getExactVersion

      VersionId getExactVersion()
      Returns:
      the exact version if this version-range is one
      Throws:
      IllegalStateException - if this version-range is not one
    • hasPrefixMatchModifier

      boolean hasPrefixMatchModifier()
      Checks whether this version-range represents a range with a prefix match modifier.
      Returns:
      true if this version-range is not a compound range and its only simple range has a prefix match modifier, false otherwise.
    • hasGreaterThanOrEqualMatchModifier

      boolean hasGreaterThanOrEqualMatchModifier()
      Checks whether this version-range represents a range with a greater or equal modifier.
      Returns:
      true if this version-range is not a compound range and its only simple range has a greater or equal modifier, false otherwise.
    • fromString

      public static VersionRange fromString(String versionRange)
      Construct a version-range by the given versionRange.
      Parameters:
      versionRange - a version-range
      Returns:
      a version-id
    • contains

      public boolean contains(String versionId)
      Check if this version-range contains the given versionId.
      Parameters:
      versionId - a version-id
      Returns:
      true if this version-range contains versionId, false otherwise.
    • contains

      public boolean contains(VersionId versionId)
      Check if this version-range contains the given versionId.
      Parameters:
      versionId - a version-id
      Returns:
      true if this version-range contains versionId, false otherwise.
    • isEqualTo

      boolean isEqualTo(VersionRange otherVersionRange)
    • equals

      public boolean equals(Object otherVersionRange)
      Overrides:
      equals in class Object
    • toString

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