com.fasterxml.jackson.core.util

## Class VersionUtil

- java.lang.Object
- - com.fasterxml.jackson.core.util.VersionUtil

-     public class VersionUtil
      extends Object

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

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `PACKAGE_VERSION_CLASS_NAME`
    `static String` | `VERSION_FILE` Deprecated. Since 2.2, use of version file is deprecated, and generated class should be used instead.

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `VersionUtil()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static Version` | `mavenVersionFor(ClassLoader classLoader, String groupId, String artifactId)` Will attempt to load the maven version for the given groupId and artifactId.
    `static Version` | `packageVersionFor(Class<?> cls)` Loads version information by introspecting a class named "PackageVersion" in the same package as the given class.
    `static Version` | `parseVersion(String versionStr)` Deprecated.
    `static Version` | `parseVersion(String versionStr, String groupId, String artifactId)`
    `protected static int` | `parseVersionPart(String partStr)`
    `static void` | `throwInternal()`
    `Version` | `version()`
    `static Version` | `versionFor(Class<?> cls)` Helper method that will try to load version information for specified class.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### VERSION_FILE

          @Deprecated
          public static final String VERSION_FILE

      Deprecated. Since 2.2, use of version file is deprecated, and generated class should be used instead.
      See Also:
        Constant Field Values

    - #### PACKAGE_VERSION_CLASS_NAME

          public static final String PACKAGE_VERSION_CLASS_NAME

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### VersionUtil

          protected VersionUtil()

  - ### Method Detail

    - #### version

          public Version version()

    - #### versionFor

          public static Version versionFor(Class<?> cls)

      Helper method that will try to load version information for specified class. Implementation is as follows: First, tries to load version info from a class named "PackageVersion" in the same package as the class. Next, if that fails, class loader that loaded specified class is asked to load resource with name "VERSION" from same location (package) as class itself had. If no version information is found, `Version.unknownVersion()` is returned.

    - #### packageVersionFor

          public static Version packageVersionFor(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 null.

    - #### mavenVersionFor

          public static Version mavenVersionFor(ClassLoader classLoader,
                                String groupId,
                                String artifactId)

      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:
        `classLoader` - the ClassLoader to load the pom.properties file from
        `groupId` - the groupId of the library
        `artifactId` - the artifactId of the library
      Returns:
        The version

    - #### parseVersion

          @Deprecated
          public static Version parseVersion(String versionStr)

      Deprecated.
      Use variant that takes three arguments instead

    - #### parseVersion

          public static Version parseVersion(String versionStr,
                             String groupId,
                             String artifactId)

    - #### parseVersionPart

          protected static int parseVersionPart(String partStr)

    - #### throwInternal

          public static final void throwInternal()

Copyright © 2012-2013 FasterXML. All Rights Reserved.