public class VersionUtil
extends java.lang.Object
Version
s.
Also contains other misc methods that have no other place to live in.
Note that this class can be used in two roles: first, as a static utility class for loading purposes, and second, as a singleton loader of per-module version information.
Note that method for accessing version information changed between versions 2.1 and 2.2; earlier code used file named "VERSION.txt"; but this has serious performance issues on some platforms (Android), so a replacement system was implemented to use class generation and dynamic class loading.
Note that functionality for reading "VERSION.txt" was removed completely from Jackson 2.6.
Modifier and Type | Field and Description |
---|---|
private Version |
_v |
private static java.util.regex.Pattern |
V_SEP |
Modifier | Constructor and Description |
---|---|
protected |
VersionUtil() |
Modifier and Type | Method and Description |
---|---|
private static void |
_close(java.io.Closeable c) |
static Version |
mavenVersionFor(java.lang.ClassLoader cl,
java.lang.String groupId,
java.lang.String artifactId)
Deprecated.
Since 2.6: functionality not used by any official Jackson component, should be
moved out if anyone needs it
|
static Version |
packageVersionFor(java.lang.Class<?> cls)
Loads version information by introspecting a class named
"PackageVersion" in the same package as the given class.
|
static Version |
parseVersion(java.lang.String s,
java.lang.String groupId,
java.lang.String artifactId)
Method used by
PackageVersion classes to decode version injected by Maven build. |
protected static int |
parseVersionPart(java.lang.String s) |
static void |
throwInternal() |
Version |
version() |
static Version |
versionFor(java.lang.Class<?> cls)
Helper method that will try to load version information for specified
class.
|
private static final java.util.regex.Pattern V_SEP
private final Version _v
public Version version()
public static Version versionFor(java.lang.Class<?> cls)
Version.unknownVersion()
is returned.public static Version packageVersionFor(java.lang.Class<?> cls)
If the class could not be found or does not have a public static Version field named "VERSION", returns null.
@Deprecated public static Version mavenVersionFor(java.lang.ClassLoader cl, java.lang.String groupId, java.lang.String artifactId)
cl
- the ClassLoader to load the pom.properties file fromgroupId
- the groupId of the libraryartifactId
- the artifactId of the librarypublic static Version parseVersion(java.lang.String s, java.lang.String groupId, java.lang.String artifactId)
PackageVersion
classes to decode version injected by Maven build.protected static int parseVersionPart(java.lang.String s)
private static final void _close(java.io.Closeable c)
public static final void throwInternal()