Top Description Fields Constructors Methods
org.apache.derby.shared.common.info

public final Class ProductVersionHolder

extends Object
Class Inheritance
Imports
java.io.InputStream, .IOException, java.util.Properties, org.apache.derby.shared.common.error.StandardException, org.apache.derby.shared.common.info.JVMInfo, org.apache.derby.shared.common.reference.ModuleUtil

Class to hold a Derby Product version. This class includes the following product version features.
  1. Save the product version information this holds as a String. We call the string a 'product version string'.
  2. Construct a ProductVersionHolder from a valid 'product version string'.
  3. Determine if two product versions are feature compatible. This means products of these versions may interoperate with ***NO*** compatibility problems.
  4. Determine if two product versions are the same. This is a stronger test than the test for feature compatibility.
Cloudscape 5.1 and older versions used the majorVersion, minorVersion, maintVersion versions directly. That is a three part version number, majorVersion.minorVersion.maintVersion, e.g. 5.1.21. For Cloudscape 5.2 onwards a four part name is required. majorVersion.minorVersion.fixPack.bugVersion e.g. 5.2.1.2 This follows the IBM standard and allows us to state that a fix pack will be 5.2.3 without worrying about how many maintence fixes there are between fix packs. We implement this using the existing format of ProductVersionHolder to reduce disruption to the code, however we make the maintVersion encode the {fixPack.bugVersion}. Since the maintVersion is represented by a int (2G values) we have plenty of room for encoding. If we assign a given majorVersion.minorVersion.fixPack a 10 year life, then we about the maximum number of individual releases it can have is 10 years * 365 days/year = 3650. Thus with the pre 5.2 scheme we would not expect a 5.1.x to have an x > 3650 (approximately). Usually the rate of point releases has been much less than one per day, 5.1.31 is released about 225 days after GA which makes around a point release every 7 days. But in the encoding we need to be conservative. With fix packs the maximum is about 2 per year and fix packs are only made to the current release, thus with a yearly minor release cycle we would imagine only 2 fixpacks per major.minor. However like other IBM products or release cycle may be extended thus we can expect up to a handful of fix packs. Thus we might imagine releases like 5.2.0.12 5.2.0.234 5.2.1.34 5.2.4.2445 but highly unlikey to have 5.2.2.59321 5.2.23.1 The encoding number must continue to increase so that the encodedMaintB > encodedMaintA if (fixPackB > fixPackA) || ((fixPackB == fixPackA) && (bugB > bugA)) Selected encoding encodedMaint = (fixPack * 1,000,000) + (bugVersion); Handles many many fixpacks and upto one million bug fixes per fix pack and remains somewhat human readable. Special fix packs fixpack == 0 = alpha (version off main codeline) fixpack == 1 = first release of major.minor (may be marked with beta) fixpack == 2 = first fix pack (displayed as 1) The drdaMaintVersion is sent in the Network Server PRDID. It never displays but may be used by the client for version specific behaviour. It should be reset to 0 with each minor release. The product version string has the form:
  productVendorName - ProductName - majorVersion.minorVersion.maintVersion [beta] - (buildNumber)

  

Field Summary

Modifier and TypeField and Description
private static final String
private static final int
private static final String
private String
private int
private Boolean
public static final int
private int
private int
private int
private String
private String
private String
private String

Constructor Summary

AccessConstructor and Description
private
private
ProductVersionHolder(String productVendorName, String productName, String productTechnologyName, int majorVersion, int minorVersion, int maintVersion, int drdaMaintVersion, String buildNumber, Boolean isBeta)

Create a ProductVersionHolder

Please see the documentation for the varient of getProductVesionHolder that takes the same parameters as this for a description of the parameters.

Method Summary

Modifier and TypeMethod and Description
public static String
fullVersionString(int major, int minor, int maint, boolean isBeta, String build)

public String

Returns:

the build number for this product.
getBuildNumber
()

Return the build number for this product.

public int

Returns:

the build number as an integer if possible,
getBuildNumberAsInt
()

Return the build number as an integer if possible, mapping from the SVN number.

public int

Returns:

the drda maintenance version number
getDrdaMaintVersion
()

Return the drda protocol maintenance version for this minor release.

public int

Returns:

the fix pack version number
getFixPackVersion
()

Return the fix pack version from the maintenance encoding.

public int

Returns:

the maintenance version number
getMaintVersion
()

Return the encoded maintainence version number.

public int

Returns:

the major version number
getMajorVersion
()

Return the major version number.

public int

Returns:

the minor version number
getMinorVersion
()

Return the minor version number.

public String

Returns:

the product name
getProductName
()

Return the external product name.

public String
public String

Returns:

the vendor name
getProductVendorName
()

Return the product vendor name.

public static ProductVersionHolder

Returns:

A valid ProductVersionHolder of null if any of the parameters provided are not valid.
getProductVersionHolder
(String
The name of the vendor
productVendorName
,
String
The name of the product. productName.length() must be greater than 0. The syntax for a product name is 'productGenus[:productSpecies]'.
productName
,
String
The technology name
productTechnologyName
,
int
The most significant portion of a 3 part product version. Must be non-negative.
majorVersion
,
int
The second portion of a 3 part product version. Must be non-negative.
minorVersion
,
int
The least significant portion of a 3 part product version. Must be non-negative.
maintVersion
,
int
The protocol modification number for minor release.
drdaMaintVersion
,
String
The buildNumber for a product.
buildNumber
,
Boolean
true iff the product is beta.
isBeta
)

Create a valid ProductVersionHolder.

public static ProductVersionHolder

Returns:

The ProductVersionHolder or null if a product with the given genus is not available in the caller's environment.
getProductVersionHolder
(Properties
The properties object that holds the productVersion information.
p
)

Get a ProductVersionHolder based on the information in the Properties object provided.

public static ProductVersionHolder

Returns:

The ProductVersionHolder or null if a product with the given genus is not available in the caller's environment.
getProductVersionHolderFromMyEnv
(String
The genus for the product.
productGenus
)

Get a ProductVersionHolder for a product of a given genus, that is available in the caller's environment.

public static ProductVersionHolder

Returns:

the product descriptor
getProductVersionHolderFromMyEnv
(InputStream
The version information
propertiesStream
)

Load the version info from the already opened properties files.

public String

Returns:

the feature version string, ie. major.minor. (e.g. 5.2)
getSimpleVersionString
()

Return the feature version string, ie.

public String

Returns:

the build version string
getVersionBuildString
(boolean
If true, include the build number
withBuild
)

Returns a short-hand value for the product version string.

public boolean

Returns:

true if this is a alpha product.
isAlpha
()

Return true if this is a alpha product.

public boolean

Returns:

true if this is a beta product.
isBeta
()

Return true if this is a beta product.

private Properties
loadProperties(String productGenus)

private static int

Returns:

the integer or a negative number if s is invalid.
parseInt
(String
A string with a non-negative integer (a sequence of decimal digits.)
s
)

Parse a string containing a non-negative integer.

public final Properties
run()

public static String

Returns:

a version string encoding the arguments
simpleVersionString
(int
Major version number
major
,
int
Minor version number
minor
,
boolean
Beta flag
isBeta
)

Convert a major and minor number with beta status into a string.

public String

Returns:

a string representation of this ProductVersion.
toString
()

Overrides java.lang.Object.toString.

Return a string representation of this ProductVersion.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

ALPHAback to summary
private static final String ALPHA
BAD_NUMBERback to summary
private static final int BAD_NUMBER
BETAback to summary
private static final String BETA
buildNumberback to summary
private String buildNumber
drdaMaintVersionback to summary
private int drdaMaintVersion
isBetaback to summary
private Boolean isBeta
MAINT_ENCODINGback to summary
public static final int MAINT_ENCODING
maintVersionback to summary
private int maintVersion
majorVersionback to summary
private int majorVersion
minorVersionback to summary
private int minorVersion
productGenusback to summary
private String productGenus
productNameback to summary
private String productName
productTechnologyNameback to summary
private String productTechnologyName
productVendorNameback to summary
private String productVendorName

Constructor Detail

ProductVersionHolderback to summary
private ProductVersionHolder()
ProductVersionHolderback to summary
private ProductVersionHolder(String productVendorName, String productName, String productTechnologyName, int majorVersion, int minorVersion, int maintVersion, int drdaMaintVersion, String buildNumber, Boolean isBeta)

Create a ProductVersionHolder

Please see the documentation for the varient of getProductVesionHolder that takes the same parameters as this for a description of the parameters.

Method Detail

fullVersionStringback to summary
public static String fullVersionString(int major, int minor, int maint, boolean isBeta, String build)
getBuildNumberback to summary
public String getBuildNumber()

Return the build number for this product.

Returns:String

the build number for this product.

getBuildNumberAsIntback to summary
public int getBuildNumberAsInt()

Return the build number as an integer if possible, mapping from the SVN number. nnnnn -> returns nnnnn nnnnnM -> returns -nnnnn indicates a modified code base nnnnn:mmmmm -> returns -nnnnn anything else -> returns -1

Returns:int

the build number as an integer if possible,

getDrdaMaintVersionback to summary
public int getDrdaMaintVersion()

Return the drda protocol maintenance version for this minor release. Starts at 0 for each minor release and only incremented when client behaviour changes based on the server version.

Returns:int

the drda maintenance version number

getFixPackVersionback to summary
public int getFixPackVersion()

Return the fix pack version from the maintenance encoding.

Returns:int

the fix pack version number

getMaintVersionback to summary
public int getMaintVersion()

Return the encoded maintainence version number.

Returns:int

the maintenance version number

getMajorVersionback to summary
public int getMajorVersion()

Return the major version number.

Returns:int

the major version number

getMinorVersionback to summary
public int getMinorVersion()

Return the minor version number.

Returns:int

the minor version number

getProductNameback to summary
public String getProductName()

Return the external product name.

Returns:String

the product name

getProductTechnologyNameback to summary
public String getProductTechnologyName()
getProductVendorNameback to summary
public String getProductVendorName()

Return the product vendor name.

Returns:String

the vendor name

getProductVersionHolderback to summary
public static ProductVersionHolder getProductVersionHolder(String productVendorName, String productName, String productTechnologyName, int majorVersion, int minorVersion, int maintVersion, int drdaMaintVersion, String buildNumber, Boolean isBeta)

Create a valid ProductVersionHolder. If any of the parameters provided is invalid, this returns null.

Parameters
productVendorName:String

The name of the vendor

productName:String

The name of the product. productName.length() must be greater than 0. The syntax for a product name is 'productGenus[:productSpecies]'.

productTechnologyName:String

The technology name

majorVersion:int

The most significant portion of a 3 part product version. Must be non-negative.

minorVersion:int

The second portion of a 3 part product version. Must be non-negative.

maintVersion:int

The least significant portion of a 3 part product version. Must be non-negative.

drdaMaintVersion:int

The protocol modification number for minor release.

buildNumber:String

The buildNumber for a product.

isBeta:Boolean

true iff the product is beta.

Returns:ProductVersionHolder

A valid ProductVersionHolder of null if any of the parameters provided are not valid.

getProductVersionHolderback to summary
public static ProductVersionHolder getProductVersionHolder(Properties p)

Get a ProductVersionHolder based on the information in the Properties object provided.

Parameters
p:Properties

The properties object that holds the productVersion information.

Returns:ProductVersionHolder

The ProductVersionHolder or null if a product with the given genus is not available in the caller's environment.

getProductVersionHolderFromMyEnvback to summary
public static ProductVersionHolder getProductVersionHolderFromMyEnv(String productGenus)

Get a ProductVersionHolder for a product of a given genus, that is available in the caller's environment. This may fail when the jar the version is being fetched from, is different to the one that loaded this class, AND the jars are in different security contexts.

Parameters
productGenus:String

The genus for the product.

Returns:ProductVersionHolder

The ProductVersionHolder or null if a product with the given genus is not available in the caller's environment.

getProductVersionHolderFromMyEnvback to summary
public static ProductVersionHolder getProductVersionHolderFromMyEnv(InputStream propertiesStream)

Load the version info from the already opened properties files. We need to do this because if the jar files (e.g. db2jtools and db2j) are in different security contexts (entries in the policy files) then we cannot load the version information for one of them correctly. This is because the this class will either have been loaded from only one of the jars and hence can only access the resource in its own jar. By making code specific to the jar open the resource we are guaranteed it will work.

Parameters
propertiesStream:InputStream

The version information

Returns:ProductVersionHolder

the product descriptor

getSimpleVersionStringback to summary
public String getSimpleVersionString()

Return the feature version string, ie. major.minor. (e.g. 5.2)

Returns:String

the feature version string, ie. major.minor. (e.g. 5.2)

getVersionBuildStringback to summary
public String getVersionBuildString(boolean withBuild)

Returns a short-hand value for the product version string. Used by Sysinfo. Includes the optional beta designation

Parameters
withBuild:boolean

If true, include the build number

Returns:String

the build version string

isAlphaback to summary
public boolean isAlpha()

Return true if this is a alpha product.

Returns:boolean

true if this is a alpha product.

isBetaback to summary
public boolean isBeta()

Return true if this is a beta product.

Returns:boolean

true if this is a beta product.

loadPropertiesback to summary
private Properties loadProperties(String productGenus)
parseIntback to summary
private static int parseInt(String s)

Parse a string containing a non-negative integer. Return a negative integer is the String is invalid.

Parameters
s:String

A string with a non-negative integer (a sequence of decimal digits.)

Returns:int

the integer or a negative number if s is invalid.

runback to summary
public final Properties run()
simpleVersionStringback to summary
public static String simpleVersionString(int major, int minor, boolean isBeta)

Convert a major and minor number with beta status into a string.

Parameters
major:int

Major version number

minor:int

Minor version number

isBeta:boolean

Beta flag

Returns:String

a version string encoding the arguments

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Return a string representation of this ProductVersion. The difference between this and createProductVersionString, is that this method retruns a String when this ProductVersionHolder holds invalid version information.

Returns:String

a string representation of this ProductVersion.