Class DependencyVersionUtil


  • @ThreadSafe
    public final class DependencyVersionUtil
    extends java.lang.Object

    A utility class to extract version numbers from file names (or other strings containing version numbers.

    Author:
    Jeremy Long
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String parsePreVersion​(java.lang.String text)
      A utility class to extract the part before version numbers from file names (or other strings containing version numbers.
      static DependencyVersion parseVersion​(java.lang.String text)
      A utility class to extract version numbers from file names (or other strings containing version numbers.
      static DependencyVersion parseVersion​(java.lang.String text, boolean firstMatchOnly)
      A utility class to extract version numbers from file names (or other strings containing version numbers.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • parseVersion

        public static DependencyVersion parseVersion​(java.lang.String text)

        A utility class to extract version numbers from file names (or other strings containing version numbers.

         Example:
         Give the file name: library-name-1.4.1r2-release.jar
         This function would return: 1.4.1.r2
        Parameters:
        text - the text being analyzed
        Returns:
        a DependencyVersion containing the version
      • parseVersion

        public static DependencyVersion parseVersion​(java.lang.String text,
                                                     boolean firstMatchOnly)

        A utility class to extract version numbers from file names (or other strings containing version numbers.

         Example:
         Give the file name: library-name-1.4.1r2-release.jar
         This function would return: 1.4.1.r2
        Parameters:
        text - the text being analyzed
        firstMatchOnly - if false and more then one version string is found in the given text, null will be returned. Otherwise, the first version found will be returned.
        Returns:
        a DependencyVersion containing the version
      • parsePreVersion

        public static java.lang.String parsePreVersion​(java.lang.String text)

        A utility class to extract the part before version numbers from file names (or other strings containing version numbers. In most cases, this part represents a more accurate name than the full file name.

         Example:
         Give the file name: library-name-1.4.1r2-release.jar
         This function would return: library-name
        Parameters:
        text - the text being analyzed
        Returns:
        the part before the version numbers if any, otherwise return the text itself.