Class VersionNumber

java.lang.Object
com.jogamp.common.util.VersionNumber
All Implemented Interfaces:
Comparable<Object>
Direct Known Subclasses:
VersionNumberString

public class VersionNumber extends Object implements Comparable<Object>
Simple version number class containing a version number either being defined explicit or derived from a string.

For the latter case, you can query whether a component has been defined explicitly by the given versionString, via hasMajor(), hasMinor() and hasSub().

The state whether a component is defined explicitly is not considered in the hashCode(), equals(Object) or compareTo(Object) methods, since the version number itself is treated regardless.

  • Field Details

    • zeroVersion

      public static final VersionNumber zeroVersion
      A zero version instance, w/o any component defined explicitly.
      See Also:
    • major

      protected final int major
    • minor

      protected final int minor
    • sub

      protected final int sub
    • strEnd

      protected final int strEnd
    • state

      protected final short state
    • HAS_MAJOR

      protected static final short HAS_MAJOR
      See Also:
    • HAS_MINOR

      protected static final short HAS_MINOR
      See Also:
    • HAS_SUB

      protected static final short HAS_SUB
      See Also:
  • Constructor Details

  • Method Details

    • getVersionNumberPattern

      public static Pattern getVersionNumberPattern(String delim)
      Returns the pattern with Perl regular expression:
         "\\D*(\\d+)[^\\"+delim+"\\s]*(?:\\"+delim+"\\D*(\\d+)[^\\"+delim+"\\s]*(?:\\"+delim+"\\D*(\\d+))?)?"
       

      A whitespace within the version number will end the parser.

      Capture groups represent the major (1), optional minor (2) and optional sub version number (3) component in this order.

      Each capture group ignores any leading non-digit and uses only contiguous digits, i.e. ignores pending non-digits.

      Parameters:
      delim - the delimiter, e.g. "."
    • getDefaultVersionNumberPattern

      public static Pattern getDefaultVersionNumberPattern()
      Returns the default pattern using getVersionNumberPattern(String) with delimiter ".".

      Instance is cached.

    • isZero

      public final boolean isZero()
      Returns true, if all version components are zero, otherwise false.
    • hasMajor

      public final boolean hasMajor()
      Returns true, if the major component is defined explicitly, otherwise false. Undefined components has the value 0.
    • hasMinor

      public final boolean hasMinor()
      Returns true, if the optional minor component is defined explicitly, otherwise false. Undefined components has the value 0.
    • hasSub

      public final boolean hasSub()
      Returns true, if the optional sub component is defined explicitly, otherwise false. Undefined components has the value 0.
    • endOfStringMatch

      public final int endOfStringMatch()
      If constructed with version-string, returns the string offset after the last matching character, or 0 if none matched, or -1 if not constructed with a string.
    • hashCode

      public final int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public final boolean equals(Object o)
      Overrides:
      equals in class Object
    • compareTo

      public final int compareTo(Object o)
      Specified by:
      compareTo in interface Comparable<Object>
    • compareTo

      public final int compareTo(VersionNumber vo)
    • getMajor

      public final int getMajor()
    • getMinor

      public final int getMinor()
    • getSub

      public final int getSub()
    • toString

      public String toString()
      Overrides:
      toString in class Object