diff options
author | Sven Gothel <[email protected]> | 2011-03-21 07:10:44 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-03-21 07:10:44 +0100 |
commit | c647362ad3a615d515f4bc7d24a0884d74471fef (patch) | |
tree | 8d1d4d966b38cf9b2069bb28d585d68fa052b4a5 /src/java/com/jogamp/common | |
parent | f20f3b7214bbd28862ae66ead6ae6aa949abdc1f (diff) |
VersionNumber: Add cstr with version number string and delimeter
Diffstat (limited to 'src/java/com/jogamp/common')
-rw-r--r-- | src/java/com/jogamp/common/util/VersionNumber.java | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/java/com/jogamp/common/util/VersionNumber.java b/src/java/com/jogamp/common/util/VersionNumber.java index 7e86e72..57c83da 100644 --- a/src/java/com/jogamp/common/util/VersionNumber.java +++ b/src/java/com/jogamp/common/util/VersionNumber.java @@ -28,6 +28,8 @@ package com.jogamp.common.util; +import java.util.StringTokenizer; + public class VersionNumber implements Comparable { protected int major; @@ -40,6 +42,33 @@ public class VersionNumber implements Comparable { sub = subMinorRev; } + /** + * @param versionString should be given as [MAJOR[.MINOR[.SUB]]] + * @param delim the delimiter, e.g. "." + */ + public VersionNumber(String versionString, String delim) { + try { + StringTokenizer tok = new StringTokenizer(versionString, delim); + if (!tok.hasMoreTokens()) { + major = 0; + return; + } + major = Integer.valueOf(tok.nextToken()).intValue(); + if (!tok.hasMoreTokens()) { + minor = 0; + return; + } + minor = Integer.valueOf(tok.nextToken()).intValue(); + if (!tok.hasMoreTokens()) { + sub = 0; + return; + } + sub = Integer.valueOf(tok.nextToken()).intValue(); + } catch (Exception e) { + throw new IllegalArgumentException("version <"+versionString+">, delim <"+delim+">", e); + } + } + protected VersionNumber() { } @Override |