Top Description Fields Constructors Methods
com.fasterxml.jackson.core.util

public Class VersionUtil

extends Object
Class Inheritance
Imports
java.io.*, java.util.Properties, java.util.regex.Pattern, com.fasterxml.jackson.core.Version, .Versioned

Functionality for supporting exposing of component Versions. 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.

Field Summary

Modifier and TypeField and Description
private static final Pattern

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
private static final void
public static Version

Returns:

The version
mavenVersionFor
(ClassLoader
the ClassLoader to load the pom.properties file from
cl
,
String
the groupId of the library
groupId
,
String
the artifactId of the library
artifactId
)

Deprecated Since 2.6: functionality not used by any official Jackson component, should be moved out if anyone needs it
Will attempt to load the maven version for the given groupId and artifactId.
public static Version

Returns:

Version information discovered if any; Version#unknownVersion() if none
packageVersionFor
(Class<?>
Class for which to look version information
cls
)

Deprecated Since 2.12 simply use versionFor(Class) instead
Alias of versionFor(Class).
public static Version

Returns:

Version instance constructed from parsed components, if successful; Version#unknownVersion() if parsing of components fail
parseVersion
(String
Version String to parse
s
,
String
Maven group id to include with version
groupId
,
String
Maven artifact id to include with version
artifactId
)

Method used by PackageVersion classes to decode version injected by Maven build.

protected static int
public static final void
public static final <T> T
public Version
version()

Deprecated
public static Version

Returns:

Version information discovered if any; Version#unknownVersion() if none
versionFor
(Class<?>
Class for which to look version information
cls
)

Loads version information by introspecting a class named "PackageVersion" in the same package as the given class.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

V_SEPback to summary
private static final Pattern V_SEP

Constructor Detail

VersionUtilback to summary
protected VersionUtil()

Method Detail

_closeback to summary
private static final void _close(Closeable c)
mavenVersionForback to summary
public static Version mavenVersionFor(ClassLoader cl, String groupId, String artifactId)

Deprecated

Since 2.6: functionality not used by any official Jackson component, should be moved out if anyone needs it

Will attempt to load the maven version for the given groupId and artifactId. Maven puts a pom.properties file in META-INF/maven/groupId/artifactId, containing the groupId, artifactId and version of the library.

Parameters
cl:ClassLoader

the ClassLoader to load the pom.properties file from

groupId:String

the groupId of the library

artifactId:String

the artifactId of the library

Returns:Version

The version

Annotations
@SuppressWarnings:resource
@Deprecated
packageVersionForback to summary
public static Version packageVersionFor(Class<?> cls)

Deprecated

Since 2.12 simply use versionFor(Class) instead

Alias of versionFor(Class).

Parameters
cls:Class<?>

Class for which to look version information

Returns:Version

Version information discovered if any; Version#unknownVersion() if none

Annotations
@Deprecated
parseVersionback to summary
public static Version parseVersion(String s, String groupId, String artifactId)

Method used by PackageVersion classes to decode version injected by Maven build.

Parameters
s:String

Version String to parse

groupId:String

Maven group id to include with version

artifactId:String

Maven artifact id to include with version

Returns:Version

Version instance constructed from parsed components, if successful; Version#unknownVersion() if parsing of components fail

parseVersionPartback to summary
protected static int parseVersionPart(String s)
throwInternalback to summary
public static final void throwInternal()
throwInternalReturnAnyback to summary
public static final <T> T throwInternalReturnAny()
versionback to summary
public Version version()

Deprecated

Annotations
@Deprecated
versionForback to summary
public static Version versionFor(Class<?> cls)

Loads version information by introspecting a class named "PackageVersion" in the same package as the given class.

If the class could not be found or does not have a public static Version field named "VERSION", returns "empty" Version returned by Version#unknownVersion().

Parameters
cls:Class<?>

Class for which to look version information

Returns:Version

Version information discovered if any; Version#unknownVersion() if none