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 beingdefined explicit
orderived from a string
.For the latter case, you can query whether a component has been defined explicitly by the given
versionString
, viahasMajor()
,hasMinor()
andhasSub()
.The state whether a component is defined explicitly is not considered in the
hashCode()
,equals(Object)
orcompareTo(Object)
methods, since the version number itself is treated regardless.
-
-
Field Summary
Fields Modifier and Type Field Description 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
Azero
version instance, w/o any component defined explicitly.
-
Constructor Summary
Constructors Modifier Constructor Description 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, String delim)
String derived version number instantiation.VersionNumber(String versionString, Pattern versionPattern)
String derived version number instantiation.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(VersionNumber vo)
int
compareTo(Object o)
int
endOfStringMatch()
If constructed withversion-string
, returns the string offset after the last matching character, or0
if none matched, or-1
if not constructed with a string.boolean
equals(Object o)
static Pattern
getDefaultVersionNumberPattern()
Returns the defaultpattern
usinggetVersionNumberPattern(String)
with delimiter ".".int
getMajor()
int
getMinor()
int
getSub()
static Pattern
getVersionNumberPattern(String delim)
Returns thepattern
with Perl regular expression:int
hashCode()
boolean
hasMajor()
Returnstrue
, if the major component is defined explicitly, otherwisefalse
.boolean
hasMinor()
Returnstrue
, if the optional minor component is defined explicitly, otherwisefalse
.boolean
hasSub()
Returnstrue
, if the optional sub component is defined explicitly, otherwisefalse
.boolean
isZero()
Returnstrue
, if all version components are zero, otherwisefalse
.String
toString()
-
-
-
Field Detail
-
zeroVersion
public static final VersionNumber zeroVersion
Azero
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 ".", seegetDefaultVersionNumberPattern()
.You can query whether a component has been defined explicitly by the given
versionString
, viahasMajor()
,hasMinor()
andhasSub()
.- 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 viagetVersionNumberPattern(String)
.You can query whether a component has been defined explicitly by the given
versionString
, viahasMajor()
,hasMinor()
andhasSub()
.- 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
, viahasMajor()
,hasMinor()
andhasSub()
.- Parameters:
versionString
- should be given as [MAJOR[.MINOR[.SUB]]]versionPattern
- thepattern
parser, must be compatible w/getVersionNumberPattern(String)
- See Also:
hasMajor()
,hasMinor()
,hasSub()
-
-
Method Detail
-
getVersionNumberPattern
public static Pattern getVersionNumberPattern(String delim)
Returns thepattern
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 defaultpattern
usinggetVersionNumberPattern(String)
with delimiter ".".Instance is cached.
-
isZero
public final boolean isZero()
Returnstrue
, if all version components are zero, otherwisefalse
.
-
hasMajor
public final boolean hasMajor()
Returnstrue
, if the major component is defined explicitly, otherwisefalse
. Undefined components has the value0
.
-
hasMinor
public final boolean hasMinor()
Returnstrue
, if the optional minor component is defined explicitly, otherwisefalse
. Undefined components has the value0
.
-
hasSub
public final boolean hasSub()
Returnstrue
, if the optional sub component is defined explicitly, otherwisefalse
. Undefined components has the value0
.
-
endOfStringMatch
public final int endOfStringMatch()
If constructed withversion-string
, returns the string offset after the last matching character, or0
if none matched, or-1
if not constructed with a string.
-
compareTo
public final int compareTo(Object o)
- Specified by:
compareTo
in interfaceComparable<Object>
-
compareTo
public final int compareTo(VersionNumber vo)
-
getMajor
public final int getMajor()
-
getMinor
public final int getMinor()
-
getSub
public final int getSub()
-
-