[Schmitzm-commits] r813 - trunk/src/skrueger/versionnumber

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Apr 22 02:08:51 CEST 2010


Author: alfonx
Date: 2010-04-22 02:08:48 +0200 (Thu, 22 Apr 2010)
New Revision: 813

Modified:
   trunk/src/skrueger/versionnumber/ReleaseUtil.java
Log:
fixed a bug in ReleaseUtil when parsing minor version

Modified: trunk/src/skrueger/versionnumber/ReleaseUtil.java
===================================================================
--- trunk/src/skrueger/versionnumber/ReleaseUtil.java	2010-04-20 17:54:24 UTC (rev 812)
+++ trunk/src/skrueger/versionnumber/ReleaseUtil.java	2010-04-22 00:08:48 UTC (rev 813)
@@ -3,6 +3,8 @@
 import java.io.InputStream;
 import java.net.URL;
 import java.util.Properties;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import org.apache.log4j.Logger;
 
@@ -188,7 +190,7 @@
 	 */
 	public static int getVersionMin(Class<?> clazz) {
 		try {
-			return Integer.parseInt(getVersion(clazz).split("\\.")[1]);
+			return extractMinVersionFromString(getVersion(clazz));
 		} catch (final Exception e) {
 			log.error("Minor version number '" + getVersion(clazz)
 					+ "' part could not be parsed from could not parsed (from "
@@ -198,6 +200,13 @@
 
 	}
 
+	public static int extractMinVersionFromString(String versionString) {
+		Pattern minVersionPattern = Pattern.compile("\\d*\\.(\\d*).*");
+		Matcher matcher = minVersionPattern.matcher(versionString);
+		matcher.find();
+		return Integer.parseInt(matcher.group(1));
+	}
+
 	/**
 	 * @param clazz
 	 *            Pass a class that resides in the same "project" or jar, where



More information about the Schmitzm-commits mailing list