com.cleancode.data
Class Version

java.lang.Object
  extended by com.cleancode.data.Version

public final class Version
extends Object

Manages version numbers for all loaded classes. By convention, each class should call getVersion (typically by assigning it to a class variable VERSION), as in:

public static final String VERSION = Version.getVersion(className , "$Revision: 9 $");

The string "$Revision: 9 $" is for RCS; substitute the appropriate designator for the source control system of your choice.

Besides returning the version number, this method will display the version number appropriately if the system has bootstrapped sufficiently. Otherwise, it is stored until system initialization has progressed, and then all collected version numbers are displayed. In either case, the display is done by a Diagnostic module which sends messages to the output channels selected via a configuration file.

Since:
CleanCode 0.9
Version:
$Revision: 9 $
Author:
Michael Sorens

Field Summary
static String VERSION
          Current version of this class.
 
Method Summary
static String getVersion(Object anObject)
          Returns the version number of the class of the passed object.
static String getVersion(Object anObject, String verString)
          Determine a version number, record it for diagnostics, and return it.
static String getVersion(String className)
          Returns the version number of the named class.
static String getVersion(String className, String verString)
          Determine a version number, record it for diagnostics, and return it.
static void syncVersionDiag()
          Once the Diagnostic class has initialized, it calls this method to change from passive to active mode, whereby versions are printed immediately rather than being collected.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION

public static final String VERSION
Current version of this class.

Method Detail

getVersion

public static String getVersion(String className,
                                String verString)
Determine a version number, record it for diagnostics, and return it. The version number is extracted from a source control version string and normalized (all decimals are printed to 2 places, so 'RCSVersion 1.1' returns '1.01'). As a side effect, the version number is output to the currently selected output channels of the Diagnostic class (which may be none).

Typically, this method should be used in a class variable assignment so it is only executed once per program invocation rather than once per instantiated object.

The display of the version number will be delayed if the Diagnostic class has not yet initialized.

Parameters:
className - name of class to which the verString applies
verString - RCS version string
Returns:
normalized version number

getVersion

public static String getVersion(Object anObject,
                                String verString)
Determine a version number, record it for diagnostics, and return it.

Parameters:
anObject - object to which the verString applies
verString - RCS version string
Returns:
normalized version number
See Also:
getVersion(String,String)

getVersion

public static String getVersion(Object anObject)
Returns the version number of the class of the passed object. Differing from the two-argument version of this method, this single-argument method has no side effects. Furthermore, anObject must have a public field VERSION whose value is returned.

Parameters:
anObject - Object to determine version of
Returns:
value of anObject's VERSION field or empty string if not found.

getVersion

public static String getVersion(String className)
Returns the version number of the named class.

Parameters:
className - name of class to determine version of
Returns:
value of anObject's VERSION field or empty string if not found.
See Also:
getVersion(Object)

syncVersionDiag

public static void syncVersionDiag()
Once the Diagnostic class has initialized, it calls this method to change from passive to active mode, whereby versions are printed immediately rather than being collected. Also, the previously collected versions are all output, in the order modules were loaded.



CleanCode Java Libraries Copyright © 2001-2012 Michael Sorens - Revised 2012.12.10 Get CleanCode at SourceForge.net. Fast, secure and Free Open Source software downloads