com.jogamp.common.util
Class VersionNumber

java.lang.Object
  extended by 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 Summary
protected static short HAS_MAJOR
           
protected static short HAS_MINOR
           
protected static short HAS_SUB
           
protected  int major
           
protected  int minor
           
protected  short state
           
protected  int strEnd
           
protected  int sub
           
static VersionNumber zeroVersion
          A zero version instance, w/o any component defined explicitly.
 
Constructor Summary
  VersionNumber(int majorRev, int minorRev, int subMinorRev)
          Explicit version number instantiation, with all components defined explicitly.
protected VersionNumber(int majorRev, int minorRev, int subMinorRev, int _strEnd, short _state)
           
  VersionNumber(String versionString)
          String derived version number instantiation.
  VersionNumber(String versionString, Pattern versionPattern)
          String derived version number instantiation.
  VersionNumber(String versionString, String delim)
          String derived version number instantiation.
 
Method Summary
 int compareTo(Object o)
           
 int compareTo(VersionNumber vo)
           
 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.
 boolean equals(Object o)
           
static Pattern getDefaultVersionNumberPattern()
          Returns the default pattern using getVersionNumberPattern(String) with delimiter ".".
 int getMajor()
           
 int getMinor()
           
 int getSub()
           
static Pattern getVersionNumberPattern(String delim)
          Returns the pattern with Perl regular expression:
 int hashCode()
           
 boolean hasMajor()
          Returns true, if the major component is defined explicitly, otherwise false.
 boolean hasMinor()
          Returns true, if the optional minor component is defined explicitly, otherwise false.
 boolean hasSub()
          Returns true, if the optional sub component is defined explicitly, otherwise false.
 boolean isZero()
          Returns true, if all version components are zero, otherwise false.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

zeroVersion

public static final VersionNumber zeroVersion
A zero version instance, w/o any component defined explicitly.

See Also:
hasMajor(), hasMinor(), hasSub()

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:
Constant Field Values

HAS_MINOR

protected static final short HAS_MINOR
See Also:
Constant Field Values

HAS_SUB

protected static final short HAS_SUB
See Also:
Constant Field Values
Constructor Detail

VersionNumber

protected VersionNumber(int majorRev,
                        int minorRev,
                        int subMinorRev,
                        int _strEnd,
                        short _state)

VersionNumber

public VersionNumber(int majorRev,
                     int minorRev,
                     int subMinorRev)
Explicit version number instantiation, with all components defined explicitly.

See Also:
hasMajor(), hasMinor(), hasSub()

VersionNumber

public VersionNumber(String versionString)
String derived version number instantiation.

Utilizing the default pattern parser with delimiter ".", see getDefaultVersionNumberPattern().

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

Parameters:
versionString - should be given as [MAJOR[.MINOR[.SUB]]]
See Also:
hasMajor(), hasMinor(), hasSub()

VersionNumber

public VersionNumber(String versionString,
                     String delim)
String derived version number instantiation.

Utilizing pattern parser created via getVersionNumberPattern(String).

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

Parameters:
versionString - should be given as [MAJOR[.MINOR[.SUB]]]
delim - the delimiter, e.g. "."
See Also:
hasMajor(), hasMinor(), hasSub()

VersionNumber

public VersionNumber(String versionString,
                     Pattern versionPattern)
String derived version number instantiation.

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

Parameters:
versionString - should be given as [MAJOR[.MINOR[.SUB]]]
versionPattern - the pattern parser, must be compatible w/ getVersionNumberPattern(String)
See Also:
hasMajor(), hasMinor(), hasSub()
Method Detail

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