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

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

public class DefaultVersionInfo
extends java.lang.Object
implements VersionInfo, java.lang.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  java.lang.String annotation
           
protected  java.util.List annotationOrder
           
protected  java.lang.String annotationRevision
           
protected  java.lang.String annotationRevSeparator
           
protected  java.lang.String annotationSeparator
           
protected  java.lang.String buildSeparator
           
protected  java.lang.String buildSpecifier
           
protected  java.lang.String component
           
protected static java.util.regex.Pattern DIGIT_SEPARATOR_PATTERN
           
protected static java.lang.String DIGIT_SEPARATOR_STRING
           
protected  java.util.List digits
           
protected  java.lang.String digitSeparator
           
static java.lang.String SNAPSHOT_IDENTIFIER
           
protected static java.util.regex.Pattern STANDARD_PATTERN
           
protected  java.lang.String strVersion
           
 
Constructor Summary
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.
 java.lang.String getAnnotation()
           
 java.util.List getAnnotationOrder()
           
 java.lang.String getAnnotationRevision()
           
 java.lang.String getBuildSpecifier()
           
 java.lang.String getComponent()
           
 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
 java.lang.String getVersionString()
          Returns a string representing the version without modification.
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
protected  java.util.List parseDigits(java.lang.String strDigits)
          Splits the string on "." and returns a list containing each digit.
protected  void parseVersion(java.lang.String version)
          Internal routine for parsing the supplied version string into its parts.
protected  void setAnnotation(java.lang.String annotation)
           
protected  void setAnnotationOrder(java.util.List annotationOrder)
           
protected  void setAnnotationRevision(java.lang.String annotationRevision)
           
protected  void setBuildSpecifier(java.lang.String buildSpecifier)
           
protected  void setComponent(java.lang.String component)
           
protected  void setDigits(java.util.List digits)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

strVersion

protected java.lang.String strVersion

component

protected java.lang.String component

digits

protected java.util.List digits

annotation

protected java.lang.String annotation

annotationRevision

protected java.lang.String annotationRevision

buildSpecifier

protected java.lang.String buildSpecifier

digitSeparator

protected java.lang.String digitSeparator

annotationSeparator

protected java.lang.String annotationSeparator

annotationRevSeparator

protected java.lang.String annotationRevSeparator

buildSeparator

protected java.lang.String buildSeparator

annotationOrder

protected java.util.List annotationOrder

SNAPSHOT_IDENTIFIER

public static final java.lang.String SNAPSHOT_IDENTIFIER
See Also:
Constant Field Values

DIGIT_SEPARATOR_STRING

protected static final java.lang.String DIGIT_SEPARATOR_STRING
See Also:
Constant Field Values

STANDARD_PATTERN

protected static final java.util.regex.Pattern STANDARD_PATTERN

DIGIT_SEPARATOR_PATTERN

protected static final java.util.regex.Pattern DIGIT_SEPARATOR_PATTERN
Constructor Detail

DefaultVersionInfo

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

Parameters:
version -
Throws:
VersionParseException
Method Detail

parseVersion

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

Parameters:
version -
Throws:
VersionParseException

isSnapshot

public boolean isSnapshot()
Description copied from interface: VersionInfo
Returns whether this represents a snapshot version. ("xxx-SNAPSHOT");

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.

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 getAnnotationOrder() is used in determining the rank order of annotations.
For example: alpha < beta < RC < release

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

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 -
Returns:

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:

getVersionString

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

Specified by:
getVersionString in interface VersionInfo
Returns:

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 -
Returns:

parseDigits

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

Parameters:
strDigits -
Returns:

getAnnotation

public java.lang.String getAnnotation()

setAnnotation

protected void setAnnotation(java.lang.String annotation)

getAnnotationRevision

public java.lang.String getAnnotationRevision()

setAnnotationRevision

protected void setAnnotationRevision(java.lang.String annotationRevision)

getComponent

public java.lang.String getComponent()

setComponent

protected void setComponent(java.lang.String component)

getDigits

public java.util.List getDigits()

setDigits

protected void setDigits(java.util.List digits)

getBuildSpecifier

public java.lang.String getBuildSpecifier()

setBuildSpecifier

protected void setBuildSpecifier(java.lang.String buildSpecifier)

getAnnotationOrder

public java.util.List getAnnotationOrder()

setAnnotationOrder

protected void setAnnotationOrder(java.util.List annotationOrder)


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