29import java.util.regex.Matcher;
74 return java.util.regex.Pattern.compile(
"\\D*(\\d+)[^\\"+delim+
"\\s]*(?:\\"+delim+
"\\D*(\\d+)[^\\"+delim+
"\\s]*(?:\\"+delim+
"\\D*(\\d+))?)?");
85 if(
null == defPattern ) {
86 synchronized( VersionNumber.class ) {
87 if(
null == defPattern ) {
94 private static volatile java.util.regex.Pattern defPattern =
null;
101 protected final static short HAS_SUB = 1 << 2 ;
103 protected VersionNumber(
final int majorRev,
final int minorRev,
final int subMinorRev,
final int _strEnd,
final short _state) {
117 public VersionNumber(
final int majorRev,
final int minorRev,
final int subMinorRev) {
173 public VersionNumber(
final String versionString,
final java.util.regex.Pattern versionPattern) {
177 final int[] val =
new int[3];
181 final Matcher matcher = versionPattern.matcher( versionString );
182 if( matcher.lookingAt() ) {
183 _strEnd = matcher.end();
184 final int groupCount = matcher.groupCount();
185 if( 1 <= groupCount ) {
186 val[0] = Integer.parseInt(matcher.group(1));
188 if( 2 <= groupCount ) {
189 val[1] = Integer.parseInt(matcher.group(2));
191 if( 3 <= groupCount ) {
192 val[2] = Integer.parseInt(matcher.group(3));
198 }
catch (
final Exception e) { }
228 int hash = 31 +
major;
229 hash = ((hash << 5) - hash) +
minor;
230 return ((hash << 5) - hash) +
sub;
234 public final boolean equals(
final Object o) {
244 final Class<?> c = (
null != o) ? o.getClass() : null ;
245 throw new ClassCastException(
"Not a VersionNumber object: " + c);
259 }
else if (
sub > vo.
sub) {
261 }
else if (
sub < vo.
sub) {
Simple version number class containing a version number either being defined explicit or derived from...
final boolean hasSub()
Returns true, if the optional sub component is defined explicitly, otherwise false.
final boolean isZero()
Returns true, if all version components are zero, otherwise false.
final int endOfStringMatch()
If constructed with version-string, returns the string offset after the last matching character,...
final int compareTo(final VersionNumber vo)
VersionNumber(final String versionString, final java.util.regex.Pattern versionPattern)
String derived version number instantiation.
static final short HAS_SUB
VersionNumber(final String versionString, final String delim)
String derived version number instantiation.
static final short HAS_MINOR
VersionNumber(final String versionString)
String derived version number instantiation.
VersionNumber(final int majorRev, final int minorRev, final int subMinorRev, final int _strEnd, final short _state)
VersionNumber(final int majorRev, final int minorRev, final int subMinorRev)
Explicit version number instantiation, with all components defined explicitly.
static final short HAS_MAJOR
final boolean hasMajor()
Returns true, if the major component is defined explicitly, otherwise false.
static final VersionNumber zeroVersion
A zero version instance, w/o any component defined explicitly.
static java.util.regex.Pattern getVersionNumberPattern(final String delim)
Returns the pattern with Perl regular expression:
final int compareTo(final Object o)
final boolean equals(final Object o)
static java.util.regex.Pattern getDefaultVersionNumberPattern()
Returns the default pattern using getVersionNumberPattern(String) with delimiter "<b>....
final boolean hasMinor()
Returns true, if the optional minor component is defined explicitly, otherwise false.