blackboard.platform.plugin
Class Version

java.lang.Object
  extended by blackboard.platform.plugin.Version

public class Version
extends java.lang.Object

Class to encapsulate the versioning in a plug-in and within the application. Versions include major, minor, patch, and build numbers, typically represented as "n.n.n.n". Comparisons go from from left to right, i.e., major to build. Since older versions did not include the concept of "build" number, the old style major, minor, patch is still supported. Undefined values for build are not evaluated.

Since:
Blackboard 5.5

Field Summary
static java.lang.String DELIMITER
          Static value for string construction and parsing.
static int EQUALS
          Static value for compare() method return value.
static int GREATER_THAN
          Static value for compare() method return value.
static int LESS_THAN
          Static value for compare() method return value.
static int UNDEFINED
          Static value for unset value.
 
Constructor Summary
Version(int maj, int min, int p)
          Constructor taking major, minor, patch number components.
Version(int maj, int min, int p, int b)
          Constructor taking all four build components.
 
Method Summary
 int compare(Version v)
          Method to evaluate two versions.
 int getBuild()
          Returns the build version number, the fourth number in a string of the form N.N.N.N
 int getMajor()
          Returns the major version number, the first number in a string of the form N.N.N.N
 int getMinor()
          Returns the minor version number, the second number in a string of the form N.N.N.N
 int getPatch()
          Returns the patch version number, the third number in a string of the form N.N.N.N
static Version parse(java.lang.String str)
          Parses a string of the form "n.n.n.n" into a Version object.
 java.lang.String toString()
          Simple method to return version as a string of the form "n.n.n.n".
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

GREATER_THAN

public static final int GREATER_THAN
Static value for compare() method return value.

See Also:
Constant Field Values

LESS_THAN

public static final int LESS_THAN
Static value for compare() method return value.

See Also:
Constant Field Values

EQUALS

public static final int EQUALS
Static value for compare() method return value.

See Also:
Constant Field Values

UNDEFINED

public static final int UNDEFINED
Static value for unset value.

See Also:
Constant Field Values

DELIMITER

public static final java.lang.String DELIMITER
Static value for string construction and parsing.

See Also:
Constant Field Values
Constructor Detail

Version

public Version(int maj,
               int min,
               int p)
Constructor taking major, minor, patch number components.

Parameters:
maj - Major version number
min - Minor version number
p - Path (or revision) version number

Version

public Version(int maj,
               int min,
               int p,
               int b)
Constructor taking all four build components.

Parameters:
maj - Major version number
min - Minor version number
p - Path (or revision) version number
b - Build version number.
Method Detail

getMajor

public int getMajor()
Returns the major version number, the first number in a string of the form N.N.N.N

Returns:
Integer for the major version number

getMinor

public int getMinor()
Returns the minor version number, the second number in a string of the form N.N.N.N

Returns:

getPatch

public int getPatch()
Returns the patch version number, the third number in a string of the form N.N.N.N

Returns:

getBuild

public int getBuild()
Returns the build version number, the fourth number in a string of the form N.N.N.N

Returns:

toString

public java.lang.String toString()
Simple method to return version as a string of the form "n.n.n.n". If patch or build are undefined, they are ommitted from the resulting string.

Overrides:
toString in class java.lang.Object
Returns:
A string of the form "n.n.n.n", where the last two numbers are optional.

compare

public int compare(Version v)
Method to evaluate two versions. Each version type is checked, in this order: major, minor, patch, and build. Patch and build may be ommitted. If so, then any number is assumed to be a match.

Parameters:
v - Version to compare against
Returns:
-1 if the value is less than v; 0 if the version is equal to v; 1 if the value is greater than v

parse

public static Version parse(java.lang.String str)
                     throws VersionException
Parses a string of the form "n.n.n.n" into a Version object. Note that patch and build numbers may be ommitted now. See compare( Version ) for information on the effect this has on comparing two versions.

Parameters:
str - String to parse
Returns:
Initialized version object
Throws:
VersionException - thrown If there are fewer than two version elements, or if any of the elements generates a parse exception


Copyright © 2003 Blackboard, Inc. All Rights Reserved.