NetKernel APIs


com.ten60.netkernel.util
Class Version

java.lang.Object
  extended bycom.ten60.netkernel.util.Version
All Implemented Interfaces:
Cloneable, Comparable

public class Version
extends Object
implements Cloneable, Comparable

Contains and manages a version number of the form "x(\.y)*". This class is NOT thread safe.

Version:
$Id: Version.java,v 1.1 2004/06/18 10:15:23 pjr Exp $
See Also:
Archive

Constructor Summary
Version()
          Create an empty version number.
Version(int major)
          Creates a new Version with a single digit version number
Version(int[] num)
          Converts an array of int to a Version.
Version(Integer[] num)
          Converts an array of Integer to a Version.
Version(int major, int minor)
          Creates a new Version with a major.minor version number.
Version(String v)
          Converts string to a version.
Version(Version v)
          Create a new Version by copying another.
 
Method Summary
protected  void __addBranch(int branch)
           
protected  void __addBranch(Integer branch)
           
 int at(int pos)
          Return the version number at the given position.
 Object clone()
           
 int compareTo(Object other)
          Compares two versions in lexigographical order.
 int compareVersions(Version ver)
          Compares two versions.
 boolean equals(Object o)
          Determine if two versions are equal.
 boolean even()
           
 boolean even(int n)
           
 Version getBase(int positions)
          Return the last number in the version number.
 Version getBranchPoint()
           
 int[] getNumbers()
          Return the current version number as an array of int.
 int hashCode()
           
 boolean isBranch()
           
 boolean isGhost()
           
 boolean isGreaterOrEqualThan(Version ver)
          Determine if this version is greater than or equal to the given one.
 boolean isGreaterThan(Version ver)
          Determine if this version is greater than the given one.
 boolean isLessOrEqualThan(Version ver)
          Determine if this version is less than or equal to the given one.
 boolean isLessThan(Version ver)
          Determine if this version is less than the given one.
 boolean isRevision()
           
 boolean isTrunk()
           
 int last()
          Return the last number in the version number.
 Version newBranch(int branch)
           
 Version next()
           
 boolean odd()
           
 boolean odd(int n)
           
 int size()
           
 String toString()
           
 String toString(int aMinLength)
           
 void toString(StringBuffer s, int aMinLength)
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Version

public Version(int major)
Creates a new Version with a single digit version number

Parameters:
major - the version number

Version

public Version(int major,
               int minor)
Creates a new Version with a major.minor version number.

Parameters:
major - the major version number

Version

public Version(Integer[] num)
Converts an array of Integer to a Version.

Parameters:
num - an array of Integers

Version

public Version(int[] num)
Converts an array of int to a Version.

Parameters:
num - an array of int

Version

public Version(String v)
        throws NumberFormatException
Converts string to a version.

Parameters:
v - a string accepted by the following regular expression. [0-9]+(.[0-9]+)*
Throws:
InvalidVersionNumberException - if the string cannot be parsed
NumberFormatException

Version

public Version(Version v)
Create a new Version by copying another.

Parameters:
v - the version to copy

Version

public Version()
Create an empty version number.

Method Detail

clone

public Object clone()

getNumbers

public int[] getNumbers()
Return the current version number as an array of int.

Returns:
the current version number as an array of int.

compareVersions

public int compareVersions(Version ver)
Compares two versions. The comparison is done the usual way, i.e., 2.0 is greter than 1.99.1, and 0.1.2 is greater than 0.1

Parameters:
ver - the version to compare to.
Returns:
0 if this == ver, 1 if this greater than ver, -1 otherwise.

compareTo

public int compareTo(Object other)
Compares two versions in lexigographical order. Unlike compareVersions, this comparison is not done in the way usual for versions numbers. The order relationship stablished here is the one CVS used to store nodes into archive files.

Specified by:
compareTo in interface Comparable
Parameters:
other - The version to compare to
See Also:
compareVersions(com.ten60.netkernel.util.Version)

isGreaterThan

public boolean isGreaterThan(Version ver)
Determine if this version is greater than the given one.

Parameters:
ver - the version to compare to.
Returns:
true if compareVersions(ver) > 0
See Also:
compareVersions(com.ten60.netkernel.util.Version)

isGreaterOrEqualThan

public boolean isGreaterOrEqualThan(Version ver)
Determine if this version is greater than or equal to the given one.

Parameters:
ver - the version to compare to.
Returns:
true if compareVersions(ver) >= 0
See Also:
compareVersions(com.ten60.netkernel.util.Version)

isLessThan

public boolean isLessThan(Version ver)
Determine if this version is less than the given one.

Parameters:
ver - the version to compare to.
Returns:
true if compareVersions(ver) < 0
See Also:
compareVersions(com.ten60.netkernel.util.Version)

isLessOrEqualThan

public boolean isLessOrEqualThan(Version ver)
Determine if this version is less than or equal to the given one.

Parameters:
ver - the version to compare to.
Returns:
true if compareVersions(ver) <= 0
See Also:
compareVersions(com.ten60.netkernel.util.Version)

equals

public boolean equals(Object o)
Determine if two versions are equal.

Parameters:
o - the version to compare to
Returns:
true if both versions represent the same version number

hashCode

public int hashCode()

at

public int at(int pos)
Return the version number at the given position.

Parameters:
pos - the position.
Returns:
the number.

last

public int last()
Return the last number in the version number.

Returns:
the number.

getBase

public Version getBase(int positions)
Return the last number in the version number.

Returns:
the number.

getBranchPoint

public Version getBranchPoint()

next

public Version next()

__addBranch

protected void __addBranch(Integer branch)

__addBranch

protected void __addBranch(int branch)

newBranch

public Version newBranch(int branch)

size

public int size()

isTrunk

public boolean isTrunk()

isBranch

public boolean isBranch()

isRevision

public boolean isRevision()

isGhost

public boolean isGhost()

even

public boolean even(int n)

even

public boolean even()

odd

public boolean odd(int n)

odd

public boolean odd()

toString

public void toString(StringBuffer s,
                     int aMinLength)

toString

public String toString()

toString

public String toString(int aMinLength)

NetKernel APIs


Copyright © 2002-2004 1060 Research Ltd. All Rights Reserved.