org.apache.maven.plugins.release.versions

Class DefaultVersionInfo

public class DefaultVersionInfo extends Object implements VersionInfo, Cloneable

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

All numbers in the "digits" part of the version are considered Integers. Therefore 1.01.01 is the same as 1.1.1 Leading zeros are ignored when performing comparisons.

Field Summary
protected Stringannotation
protected ListannotationOrder
protected StringannotationRevision
protected StringannotationRevSeparator
protected StringannotationSeparator
protected StringbuildSeparator
protected StringbuildSpecifier
protected Stringcomponent
protected Listdigits
protected StringdigitSeparator
protected static PatternDIGIT_SEPARATOR_PATTERN
protected static StringDIGIT_SEPARATOR_STRING
protected StringstrVersion
static StringSNAPSHOT_IDENTIFIER
protected static PatternSTANDARD_PATTERN
Constructor Summary
DefaultVersionInfo(String version)
Constructs this object and parses the supplied version string.
Method Summary
intcompareTo(Object obj)
Compares this {@link DefaultVersionInfo} to the supplied {@link DefaultVersionInfo} to determine which version is greater.
StringgetAnnotation()
ListgetAnnotationOrder()
StringgetAnnotationRevision()
StringgetBuildSpecifier()
StringgetComponent()
ListgetDigits()
VersionInfogetNextVersion()
StringgetReleaseVersionString()
StringgetSnapshotVersionString()
StringgetVersionString()
protected static StringgetVersionString(DefaultVersionInfo info, String buildSpecifier, String buildSeparator)
protected StringincrementVersionString(String s)
Takes a string and increments it as an integer.
booleanisSnapshot()
protected static StringjoinDigitString(List digits)
Simply joins the items in the list with "." period
protected ListparseDigits(String strDigits)
Splits the string on "." and returns a list containing each digit.
protected voidparseVersion(String version)
Internal routine for parsing the supplied version string into its parts.
protected voidsetAnnotation(String annotation)
protected voidsetAnnotationOrder(List annotationOrder)
protected voidsetAnnotationRevision(String annotationRevision)
protected voidsetBuildSpecifier(String buildSpecifier)
protected voidsetComponent(String component)
protected voidsetDigits(List digits)

Field Detail

annotation

protected String annotation

annotationOrder

protected List annotationOrder

annotationRevision

protected String annotationRevision

annotationRevSeparator

protected String annotationRevSeparator

annotationSeparator

protected String annotationSeparator

buildSeparator

protected String buildSeparator

buildSpecifier

protected String buildSpecifier

component

protected String component

digits

protected List digits

digitSeparator

protected String digitSeparator

DIGIT_SEPARATOR_PATTERN

protected static final Pattern DIGIT_SEPARATOR_PATTERN

DIGIT_SEPARATOR_STRING

protected static final String DIGIT_SEPARATOR_STRING

strVersion

protected String strVersion

SNAPSHOT_IDENTIFIER

public static final String SNAPSHOT_IDENTIFIER

STANDARD_PATTERN

protected static final Pattern STANDARD_PATTERN

Constructor Detail

DefaultVersionInfo

public DefaultVersionInfo(String version)
Constructs this object and parses the supplied version string.

Parameters: version

Method Detail

compareTo

public int compareTo(Object obj)
Compares this {@link DefaultVersionInfo} to the supplied {@link DefaultVersionInfo} to determine which version is greater.

Decision order is: digits, annotation, annotationRev, buildSpecifier.

Presence of an annotation is considered to be less than an equivalent version without an annotation.
Example: 1.0 is greater than 1.0-alpha.

The {@link DefaultVersionInfo#getAnnotationOrder()} is used in determining the rank order of annotations.
For example: alpha < beta < RC < release

Parameters: that

Returns:

Throws: IllegalArgumentException if the components differ between the objects or if either of the annotations can not be determined.

getAnnotation

public String getAnnotation()

getAnnotationOrder

public List getAnnotationOrder()

getAnnotationRevision

public String getAnnotationRevision()

getBuildSpecifier

public String getBuildSpecifier()

getComponent

public String getComponent()

getDigits

public List getDigits()

getNextVersion

public VersionInfo getNextVersion()

getReleaseVersionString

public String getReleaseVersionString()

getSnapshotVersionString

public String getSnapshotVersionString()

getVersionString

public String getVersionString()

getVersionString

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

incrementVersionString

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

Parameters: s

Returns:

isSnapshot

public boolean isSnapshot()

joinDigitString

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

Parameters: digits

Returns:

parseDigits

protected List parseDigits(String strDigits)
Splits the string on "." and returns a list containing each digit.

Parameters: strDigits

Returns:

parseVersion

protected void parseVersion(String version)
Internal routine for parsing the supplied version string into its parts.

Parameters: version

setAnnotation

protected void setAnnotation(String annotation)

setAnnotationOrder

protected void setAnnotationOrder(List annotationOrder)

setAnnotationRevision

protected void setAnnotationRevision(String annotationRevision)

setBuildSpecifier

protected void setBuildSpecifier(String buildSpecifier)

setComponent

protected void setComponent(String component)

setDigits

protected void setDigits(List digits)
Copyright © 2002-2007 Apache Software Foundation. All Rights Reserved.