nl.toolforge.karma.core
Class Version

java.lang.Object
  extended bynl.toolforge.karma.core.Version
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable
Direct Known Subclasses:
Patch

public class Version
extends java.lang.Object
implements java.lang.Cloneable, java.lang.Comparable

A Version is the container object for the version attribute of a module. The implementation is independent of the version control system.

Version:
$Id: Version.java,v 1.12 2004/11/02 22:57:08 amooy Exp $
Author:
D.A. Smedes

Field Summary
static int FIRST_DIGIT
           
static Version INITIAL_VERSION
          The initial version for a module.
static int SECOND_DIGIT
           
static int THIRD_DIGIT
           
static java.lang.String VERSION_PATTERN_STRING
           
static java.lang.String VERSION_SEPARATOR_CHAR
          Separator for version digits.
 
Constructor Summary
Version(int[] versionDigits)
          Constructs a version number concatenating each item in versionDigits, using the '-' separator.
Version(java.lang.String versionIdentifier)
          Constructs a version number using the versionIdentifier parameter.
 
Method Summary
 java.lang.Object clone()
           
 int compareTo(java.lang.Object o)
          Compares two Version instances.
 Patch createPatch(int patchNumber)
          Creates a Patch based on this version.
 boolean equals(java.lang.Object o)
           
protected static Version getInitialVersion()
          Returns the initial version for a module.
 java.lang.String getPatternString()
           
 java.lang.String getVersionNumber()
           
 int hashCode()
           
 void increase()
          Increases this versions' last digit by 1.
 void increaseMajor()
          Increases this Version to the next major version by increasing the first digit of the version and setting the second digit to "0".
 boolean isHigherThan(Version version)
           
 boolean isLowerThan(Version version)
           
 void setDigit(int index, int nextDigit)
           
 java.lang.String toString()
          Gets the string representation of this version.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

VERSION_PATTERN_STRING

public static java.lang.String VERSION_PATTERN_STRING

VERSION_SEPARATOR_CHAR

public static final java.lang.String VERSION_SEPARATOR_CHAR
Separator for version digits.

See Also:
Constant Field Values

INITIAL_VERSION

public static Version INITIAL_VERSION
The initial version for a module.


FIRST_DIGIT

public static final int FIRST_DIGIT
See Also:
Constant Field Values

SECOND_DIGIT

public static final int SECOND_DIGIT
See Also:
Constant Field Values

THIRD_DIGIT

public static final int THIRD_DIGIT
See Also:
Constant Field Values
Constructor Detail

Version

public Version(java.lang.String versionIdentifier)
Constructs a version number using the versionIdentifier parameter.

Parameters:
versionIdentifier -

Version

public Version(int[] versionDigits)
Constructs a version number concatenating each item in versionDigits, using the '-' separator. {1, 0, 9} translates into a version number 1-0-9.

Parameters:
versionDigits - An array, containing all version components (maximum of three is allowed).
Method Detail

getPatternString

public java.lang.String getPatternString()

getInitialVersion

protected static Version getInitialVersion()
Returns the initial version for a module. Right now, this is implemented as new Version("0-0").

Returns:

createPatch

public Patch createPatch(int patchNumber)
Creates a Patch based on this version.

Parameters:
patchNumber -
Returns:

getVersionNumber

public java.lang.String getVersionNumber()

toString

public java.lang.String toString()
Gets the string representation of this version.

Returns:
A string representation of this version.

hashCode

public final int hashCode()

equals

public final boolean equals(java.lang.Object o)

compareTo

public final int compareTo(java.lang.Object o)
Compares two Version instances.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - The other Version instance to match against.
Returns:
Returns -1 when this < o, 0 when this == o or 1 when this > o.

setDigit

public void setDigit(int index,
                     int nextDigit)

isLowerThan

public final boolean isLowerThan(Version version)

isHigherThan

public final boolean isHigherThan(Version version)

increase

public final void increase()
Increases this versions' last digit by 1.


increaseMajor

public void increaseMajor()
Increases this Version to the next major version by increasing the first digit of the version and setting the second digit to "0".


clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Throws:
java.lang.CloneNotSupportedException


Copyright © 2002-2004 Toolforge. All Rights Reserved.