Class DefaultVersionInfo

java.lang.Object
org.apache.maven.shared.release.versions.DefaultVersionInfo
All Implemented Interfaces:
Comparable<VersionInfo>, VersionInfo

public class DefaultVersionInfo extends Object implements VersionInfo
This compares and increments versions for a common java versioning scheme.

The supported version scheme has the following parts.
component-digits-annotation-annotationRevision-buildSpecifier
Example:
my-component-1.0.1-alpha-2-SNAPSHOT Terms:

  • component - name of the versioned component (log4j, commons-lang, etc)
  • digits - Numeric digits with at least one "." period. (1.0, 1.1, 1.01, 1.2.3, etc)
  • annotationRevision - Integer qualifier for the annotation. (4 as in RC-4)
  • buildSpecifier - Additional specifier for build. (SNAPSHOT, or build number like "20041114.081234-2")
Digits is the only required piece of the version string, and must contain at lease one "." period. Implementation details:
The separators "_" and "-" between components are also optional (though they are usually recommended).
Example:
log4j-1.2.9-beta-9-SNAPSHOT == log4j1.2.9beta9SNAPSHOT == log4j_1.2.9_beta_9_SNAPSHOT Leading zeros are significant when performing comparisons. TODO: this parser is better than DefaultArtifactVersion - replace it with this (but align naming) and then remove this from here.
  • Field Details

    • STANDARD_PATTERN

      public static final Pattern STANDARD_PATTERN
      Constant STANDARD_PATTERN
    • ALTERNATE_PATTERN

      public static final Pattern ALTERNATE_PATTERN
      Constant ALTERNATE_PATTERN
  • Constructor Details

    • DefaultVersionInfo

      public DefaultVersionInfo(String version) throws VersionParseException
      Constructs this object and parses the supplied version string.
      Parameters:
      version - the version string
      Throws:
      VersionParseException - if an exception during parsing the input
    • DefaultVersionInfo

      public DefaultVersionInfo(List<String> digits, String annotation, String annotationRevision, String buildSpecifier, String annotationSeparator, String annotationRevSeparator, String buildSeparator)

      Constructor for DefaultVersionInfo.

      Parameters:
      digits - a List object
      annotation - a String object
      annotationRevision - a String object
      buildSpecifier - a String object
      annotationSeparator - a String object
      annotationRevSeparator - a String object
      buildSeparator - a String object
  • Method Details

    • isSnapshot

      public boolean isSnapshot()
      Description copied from interface: VersionInfo
      Returns whether this represents a snapshot version.
      Specified by:
      isSnapshot in interface VersionInfo
      Returns:
      true if the original value was a snapshot, otherwise false
    • getNextVersion

      public VersionInfo getNextVersion()
      Description copied from interface: VersionInfo
      Returns a VersionInfo object which represents the next version of this object.
      Specified by:
      getNextVersion in interface VersionInfo
      Returns:
      the next VersionInfo
    • compareTo

      public int compareTo(VersionInfo obj)
      Compares this DefaultVersionInfo to the supplied DefaultVersionInfo to determine which version is greater.
      Specified by:
      compareTo in interface Comparable<VersionInfo>
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • incrementVersionString

      protected String incrementVersionString(String s)
      Takes a string and increments it as an integer. Preserves any lpad of "0" zeros.
      Parameters:
      s - the version number
      Returns:
      String increments the input String as an integer and Preserves any lpad of "0" zeros.
    • getSnapshotVersionString

      public String getSnapshotVersionString()
      Description copied from interface: VersionInfo
      Returns a string representing the version with a snapshot specification
      Specified by:
      getSnapshotVersionString in interface VersionInfo
      Returns:
      the snapshot version transformation of the original value
    • getReleaseVersionString

      public String getReleaseVersionString()
      Description copied from interface: VersionInfo
      Returns a string representing the version without a snapshot specification.
      Specified by:
      getReleaseVersionString in interface VersionInfo
      Returns:
      the final version transformation of the original value
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getVersionString

      protected static String getVersionString(DefaultVersionInfo info, String buildSpecifier, String buildSeparator)

      getVersionString.

      Parameters:
      info - a DefaultVersionInfo object
      buildSpecifier - a String object
      buildSeparator - a String object
      Returns:
      a String object
    • joinDigitString

      protected static String joinDigitString(List<String> digits)
      Simply joins the items in the list with "." period
      Parameters:
      digits - List<String> of digits
      Returns:
      a single String of the items in the passed list, joined with a "."
    • getDigits

      public List<String> getDigits()

      Getter for the field digits.

      Returns:
      a List object
    • getAnnotation

      public String getAnnotation()

      Getter for the field annotation.

      Returns:
      a String object
    • getAnnotationRevision

      public String getAnnotationRevision()

      Getter for the field annotationRevision.

      Returns:
      a String object
    • getBuildSpecifier

      public String getBuildSpecifier()

      Getter for the field buildSpecifier.

      Returns:
      a String object