com.townleyenterprises.common
Class Version

java.lang.Object
  extended bycom.townleyenterprises.common.Version

public final class Version
extends java.lang.Object

This class provides version information for the te-common project. It allows easy version checking from client user applications to enforce dependency checking on a particular release (if required).

Since:
2.1
Version:
$Id: Version.java.in,v 1.11 2004/07/30 16:22:09 atownley Exp $
Author:
Andrew S. Townley

Nested Class Summary
static class Version.VersionMismatchException
          This exception is used to report version requirement failures.
 
Field Summary
static java.lang.String BUILD
          this is the sequential number of the official builds
static java.lang.String DATE
          this is the date on which the build was performed
static int MAJOR
          this is the major version number of the build
static int MINOR
          this is the minor version number of the build.
static java.lang.String PROJECT
          this is the project to which the version refers
static java.lang.String RELEASE
          this is the release number of the build in question
 
Method Summary
static int compare(int maj1, int min1, java.lang.String rel1, java.lang.String bld1, int maj2, int min2, java.lang.String rel2, java.lang.String bld2)
          This utility method is used to compare two sets of version values and report how they relate to each other.
static int compare(java.lang.String[] ver1, java.lang.String[] ver2)
          This version of compare deals with arrays of 4 string values (as parsed by the parse method) instead of the 8 string values.
static int compare(java.lang.String verstr1, java.lang.String verstr2)
          This version of compare deals with two version strings which are expected to be in the format provided by either getVersion() or getFullVersion().
static java.lang.String getBuild()
          This method is used to just retrieve the build portion of the version number.
static java.lang.String getFullVersion()
          This method is used to retrieve the formatted version number suitable for displaying in about boxes, version outputs, log files, etc.
static java.lang.String getVersion()
          This method is used to just get the formatted version number without the build information.
static void main(java.lang.String[] args)
           
static java.lang.String[] parse(java.lang.String verstr)
          This method is used to parse the supplied string into an array of String objects representing the version in the format: major.minor.release (Build build[; date]).
static void require(int rmaj, int rmin, int rrel, int rbuild)
          This method is used to require the specific minimum version of the library be available.
static void require(java.lang.String checkver)
          This is an overloaded version of require which facilitates easier version checking.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROJECT

public static final java.lang.String PROJECT
this is the project to which the version refers

See Also:
Constant Field Values

MAJOR

public static final int MAJOR
this is the major version number of the build

See Also:
Constant Field Values

MINOR

public static final int MINOR
this is the minor version number of the build.

See Also:
Constant Field Values

RELEASE

public static final java.lang.String RELEASE
this is the release number of the build in question

See Also:
Constant Field Values

BUILD

public static final java.lang.String BUILD
this is the sequential number of the official builds

See Also:
Constant Field Values

DATE

public static final java.lang.String DATE
this is the date on which the build was performed

See Also:
Constant Field Values
Method Detail

getFullVersion

public static java.lang.String getFullVersion()
This method is used to retrieve the formatted version number suitable for displaying in about boxes, version outputs, log files, etc.

Returns:
the formatted version string

getVersion

public static java.lang.String getVersion()
This method is used to just get the formatted version number without the build information.

Returns:
the version string

getBuild

public static java.lang.String getBuild()
This method is used to just retrieve the build portion of the version number.

Returns:
the build information

require

public static void require(int rmaj,
                           int rmin,
                           int rrel,
                           int rbuild)
                    throws Version.VersionMismatchException
This method is used to require the specific minimum version of the library be available. If the requested version or newer is not available, an exception is thrown.

In this case, newer means numerically later with the special exception of DEVELOPER builds, which will automatically always succeed. For prerelease builds, the -pre# suffix should be omitted and the build number should be used instead.

Parameters:
rmaj - the required major version
rmin - the required minor version
rrel - the required release number
rbuild - the required build number
Throws:
Version.VersionMismatchException - if the requested version is not available
java.lang.NumberFormatException - if the required numeric values can't be converted to numbers

require

public static void require(java.lang.String checkver)
                    throws Version.VersionMismatchException
This is an overloaded version of require which facilitates easier version checking.

Parameters:
checkver - the version of the required build
Throws:
Version.VersionMismatchException - if the requested version is not available
java.lang.NumberFormatException - if the required numeric values can't be converted to numbers

compare

public static int compare(int maj1,
                          int min1,
                          java.lang.String rel1,
                          java.lang.String bld1,
                          int maj2,
                          int min2,
                          java.lang.String rel2,
                          java.lang.String bld2)
This utility method is used to compare two sets of version values and report how they relate to each other. If any of the version strings contain a release of DEVELOPER, that version will always be greater than the other.

Parameters:
maj1 - the fist major version
min1 - the fist minor version
rel1 - the fist release number
bld1 - the fist build number
maj2 - the fist major version
min2 - the fist minor version
rel2 - the fist release number
bld2 - the fist build number
Returns:
< 0 if the first is less than the second; 0 if they are equal or > 0 if the first is greater than the second

compare

public static int compare(java.lang.String[] ver1,
                          java.lang.String[] ver2)
This version of compare deals with arrays of 4 string values (as parsed by the parse method) instead of the 8 string values.

Parameters:
ver1 - the string array for version 1
ver2 - the string array for version 2
Returns:
< 0 if the first is less than the second; 0 if they are equal or > 0 if the first is greater than the second

compare

public static int compare(java.lang.String verstr1,
                          java.lang.String verstr2)
This version of compare deals with two version strings which are expected to be in the format provided by either getVersion() or getFullVersion().

Parameters:
verstr1 - the first version string
verstr2 - the second version string
Returns:
< 0 if the first is less than the second; 0 if they are equal or > 0 if the first is greater than the second

parse

public static java.lang.String[] parse(java.lang.String verstr)
This method is used to parse the supplied string into an array of String objects representing the version in the format: major.minor.release (Build build[; date]). If it doesn't match this format, an empty array is returned.

Parameters:
verstr - the version string
Returns:
the array containing the individual values

main

public static void main(java.lang.String[] args)


Copyright © 2002-2004, Andrew S. Townley and Townley Enterprises. All Rights Reserved.
This project is hosted on http://te-code.sourceforge.net.