Class VersionNumber
- All Implemented Interfaces:
Comparable<Object>
- Direct Known Subclasses:
VersionNumberString
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
FieldsModifier and TypeFieldDescriptionprotected static final shortprotected static final shortprotected static final shortprotected final intprotected final intprotected final shortprotected final intprotected final intstatic final VersionNumberAzeroversion instance, w/o any component defined explicitly. -
Constructor Summary
ConstructorsModifierConstructorDescriptionVersionNumber(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
Modifier and TypeMethodDescriptionfinal intfinal intfinal intIf constructed withversion-string, returns the string offset after the last matching character, or0if none matched, or-1if not constructed with a string.final booleanstatic PatternReturns the defaultpatternusinggetVersionNumberPattern(String)with delimiter ".".final intgetMajor()final intgetMinor()final intgetSub()static PatterngetVersionNumberPattern(String delim) Returns thepatternwith Perl regular expression:final inthashCode()final booleanhasMajor()Returnstrue, if the major component is defined explicitly, otherwisefalse.final booleanhasMinor()Returnstrue, if the optional minor component is defined explicitly, otherwisefalse.final booleanhasSub()Returnstrue, if the optional sub component is defined explicitly, otherwisefalse.final booleanisZero()Returnstrue, if all version components are zero, otherwisefalse.toString()
-
Field Details
-
zeroVersion
Azeroversion 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
-
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:
-
VersionNumber
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:
-
VersionNumber
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:
-
VersionNumber
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:
-
-
Method Details
-
getVersionNumberPattern
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
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. -
hashCode
public final int hashCode() -
equals
-
compareTo
- Specified by:
compareToin interfaceComparable<Object>
-
compareTo
-
getMajor
public final int getMajor() -
getMinor
public final int getMinor() -
getSub
public final int getSub() -
toString
-