Class DependencyVersionUtil

java.lang.Object
org.owasp.dependencycheck.utils.DependencyVersionUtil

@ThreadSafe public final class DependencyVersionUtil extends Object

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

Author:
Jeremy Long
  • Method Details

    • parseVersion

      public static DependencyVersion parseVersion(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(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 String parsePreVersion(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.