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 explicitorderived 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 shortHAS_MAJORprotected static shortHAS_MINORprotected static shortHAS_SUBprotected intmajorprotected intminorprotected shortstateprotected intstrEndprotected intsubstatic VersionNumberzeroVersionAzeroversion 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.protectedVersionNumber(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 intcompareTo(VersionNumber vo)intcompareTo(Object o)intendOfStringMatch()If constructed withversion-string, returns the string offset after the last matching character, or0if none matched, or-1if not constructed with a string.booleanequals(Object o)static PatterngetDefaultVersionNumberPattern()Returns the defaultpatternusinggetVersionNumberPattern(String)with delimiter ".".intgetMajor()intgetMinor()intgetSub()static PatterngetVersionNumberPattern(String delim)Returns thepatternwith Perl regular expression:inthashCode()booleanhasMajor()Returnstrue, if the major component is defined explicitly, otherwisefalse.booleanhasMinor()Returnstrue, if the optional minor component is defined explicitly, otherwisefalse.booleanhasSub()Returnstrue, if the optional sub component is defined explicitly, otherwisefalse.booleanisZero()Returnstrue, if all version components are zero, otherwisefalse.StringtoString()
-
-
-
Field Detail
-
zeroVersion
public static final VersionNumber zeroVersion
Azeroversion 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
patternparser 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
patternparser 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- thepatternparser, must be compatible w/getVersionNumberPattern(String)- See Also:
hasMajor(),hasMinor(),hasSub()
-
-
Method Detail
-
getVersionNumberPattern
public static Pattern getVersionNumberPattern(String delim)
Returns thepatternwith 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 defaultpatternusinggetVersionNumberPattern(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, or0if none matched, or-1if not constructed with a string.
-
compareTo
public final int compareTo(Object o)
- Specified by:
compareToin interfaceComparable<Object>
-
compareTo
public final int compareTo(VersionNumber vo)
-
getMajor
public final int getMajor()
-
getMinor
public final int getMinor()
-
getSub
public final int getSub()
-
-