3 |
import java.io.InputStream; |
import java.io.InputStream; |
4 |
import java.net.URL; |
import java.net.URL; |
5 |
import java.util.Properties; |
import java.util.Properties; |
6 |
|
import java.util.regex.Matcher; |
7 |
|
import java.util.regex.Pattern; |
8 |
|
|
9 |
import org.apache.log4j.Logger; |
import org.apache.log4j.Logger; |
10 |
|
|
190 |
*/ |
*/ |
191 |
public static int getVersionMin(Class<?> clazz) { |
public static int getVersionMin(Class<?> clazz) { |
192 |
try { |
try { |
193 |
return Integer.parseInt(getVersion(clazz).split("\\.")[1]); |
return extractMinVersionFromString(getVersion(clazz)); |
194 |
} catch (final Exception e) { |
} catch (final Exception e) { |
195 |
log.error("Minor version number '" + getVersion(clazz) |
log.error("Minor version number '" + getVersion(clazz) |
196 |
+ "' part could not be parsed from could not parsed (from " |
+ "' part could not be parsed from could not parsed (from " |
200 |
|
|
201 |
} |
} |
202 |
|
|
203 |
|
public static int extractMinVersionFromString(String versionString) { |
204 |
|
Pattern minVersionPattern = Pattern.compile("\\d*\\.(\\d*).*"); |
205 |
|
Matcher matcher = minVersionPattern.matcher(versionString); |
206 |
|
matcher.find(); |
207 |
|
return Integer.parseInt(matcher.group(1)); |
208 |
|
} |
209 |
|
|
210 |
/** |
/** |
211 |
* @param clazz |
* @param clazz |
212 |
* Pass a class that resides in the same "project" or jar, where |
* Pass a class that resides in the same "project" or jar, where |