org.apache.maven.shared.release.versions
Class DefaultVersionInfo

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

public class DefaultVersionInfo
extends java.lang.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

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 reccommended).
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.


Constructor Summary
DefaultVersionInfo(java.util.List digits, java.lang.String annotation, java.lang.String annotationRevision, java.lang.String buildSpecifier, java.lang.String annotationSeparator, java.lang.String annotationRevSeparator, java.lang.String buildSeparator)
           
DefaultVersionInfo(java.lang.String version)
          Constructs this object and parses the supplied version string.
 
Method Summary
 int compareTo(java.lang.Object obj)
          Compares this DefaultVersionInfo to the supplied DefaultVersionInfo to determine which version is greater.
 boolean equals(java.lang.Object obj)
           
 java.lang.String getAnnotation()
           
 java.lang.String getAnnotationRevision()
           
 java.lang.String getBuildSpecifier()
           
 java.util.List getDigits()
           
 VersionInfo getNextVersion()
          Returns a VersionInfo object which represents the next version of this object.
 java.lang.String getReleaseVersionString()
          Returns a string representing the version without a snapshot specification.
 java.lang.String getSnapshotVersionString()
          Returns a string representing the version with a snapshot specification
protected static java.lang.String getVersionString(DefaultVersionInfo info, java.lang.String buildSpecifier, java.lang.String buildSeparator)
           
protected  java.lang.String incrementVersionString(java.lang.String s)
          Takes a string and increments it as an integer.
 boolean isSnapshot()
          Returns whether this represents a snapshot version.
protected static java.lang.String joinDigitString(java.util.List digits)
          Simply joins the items in the list with "." period
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultVersionInfo

public DefaultVersionInfo(java.lang.String version)
                   throws VersionParseException
Constructs this object and parses the supplied version string.

Parameters:
version -
Throws:
VersionParseException

DefaultVersionInfo

public DefaultVersionInfo(java.util.List digits,
                          java.lang.String annotation,
                          java.lang.String annotationRevision,
                          java.lang.String buildSpecifier,
                          java.lang.String annotationSeparator,
                          java.lang.String annotationRevSeparator,
                          java.lang.String buildSeparator)
Method Detail

isSnapshot

public boolean isSnapshot()
Description copied from interface: VersionInfo
Returns whether this represents a snapshot version.

Specified by:
isSnapshot in interface VersionInfo
Returns:

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:

compareTo

public int compareTo(java.lang.Object obj)
Compares this DefaultVersionInfo to the supplied DefaultVersionInfo to determine which version is greater.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
obj - the comparison version
Returns:
the comparison value
Throws:
java.lang.IllegalArgumentException - if the components differ between the objects or if either of the annotations can not be determined.

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

incrementVersionString

protected java.lang.String incrementVersionString(java.lang.String s)
Takes a string and increments it as an integer. Preserves any lpad of "0" zeros.

Parameters:
s -

getSnapshotVersionString

public java.lang.String getSnapshotVersionString()
Description copied from interface: VersionInfo
Returns a string representing the version with a snapshot specification

Specified by:
getSnapshotVersionString in interface VersionInfo
Returns:

getReleaseVersionString

public java.lang.String getReleaseVersionString()
Description copied from interface: VersionInfo
Returns a string representing the version without a snapshot specification.

Specified by:
getReleaseVersionString in interface VersionInfo
Returns:

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getVersionString

protected static java.lang.String getVersionString(DefaultVersionInfo info,
                                                   java.lang.String buildSpecifier,
                                                   java.lang.String buildSeparator)

joinDigitString

protected static java.lang.String joinDigitString(java.util.List digits)
Simply joins the items in the list with "." period

Parameters:
digits -

getDigits

public java.util.List getDigits()

getAnnotation

public java.lang.String getAnnotation()

getAnnotationRevision

public java.lang.String getAnnotationRevision()

getBuildSpecifier

public java.lang.String getBuildSpecifier()


Copyright © 2002-2009 Apache Software Foundation. All Rights Reserved.