org.eclipse.datatools.sqltools.sqlbuilder.model
Class DBVersionHelper

java.lang.Object
  extended by org.eclipse.datatools.sqltools.sqlbuilder.model.DBVersionHelper

public class DBVersionHelper
extends java.lang.Object

This class provides database product (platform) and version information for a particular database. The database version consists of three integers: version, release, and mod level. This class supports comparisons between versions, as well as comparisons against specified version, release, and mod levels. Note: this class is adapted from Development Center's DB2Version class.

Author:
bpayton

Field Summary
static java.lang.String DEFAULT_FAMILY
           
static java.lang.String DEFAULT_PRODUCT
           
static java.lang.String DEFAULT_VERSION_STRING
           
static java.lang.String FAMILY_CLOUDSCAPE
           
static java.lang.String FAMILY_DB2
           
static java.lang.String FAMILY_INFORMIX
           
static java.lang.String FAMILY_MYSQL
           
static java.lang.String FAMILY_ORACLE
           
static java.lang.String FAMILY_SQL_SERVER
           
static java.lang.String FAMILY_SYBASE
           
static java.lang.String ID_APACHE_DERBY
           
static java.lang.String ID_AS
           
static java.lang.String ID_AS400
           
static java.lang.String ID_DB2
           
static java.lang.String ID_DB2_EVERYPLACE
           
static java.lang.String ID_DB2_PREFIX
           
static java.lang.String ID_DB2_UDB
           
static java.lang.String ID_DB2_UDB_AS400
           
static java.lang.String ID_DB2_UDB_ISERIES
           
static java.lang.String ID_DB2_UDB_ZSERIES
           
static java.lang.String ID_DB2400_SQL
           
static java.lang.String ID_DERBY
           
static java.lang.String ID_IBM_CLOUDSCAPE
           
static java.lang.String ID_INFORMIX
           
static java.lang.String ID_MYSQL
           
static java.lang.String ID_ORACLE
           
static java.lang.String ID_SQL_SERVER
           
static java.lang.String ID_SQLDS
           
static java.lang.String ID_SYBASE_ASA
           
static java.lang.String ID_SYBASE_ASE
           
static java.lang.String ID_WORKSTATION
           
static java.lang.String PRODUCT_CLOUDSCAPE
           
static java.lang.String PRODUCT_DB2_EVERYPLACE
           
static java.lang.String PRODUCT_DB2_ISERIES
           
static java.lang.String PRODUCT_DB2_LUW
           
static java.lang.String PRODUCT_DB2_VMVSE
           
static java.lang.String PRODUCT_DB2_ZOS
           
static java.lang.String PRODUCT_DERBY
           
static java.lang.String PRODUCT_INFORMIX
           
static java.lang.String PRODUCT_MYSQL
           
static java.lang.String PRODUCT_ORACLE
           
static java.lang.String PRODUCT_SQL_SERVER
           
static java.lang.String PRODUCT_SYBASE_ASA
           
static java.lang.String PRODUCT_SYBASE_ASE
           
 
Constructor Summary
DBVersionHelper()
          Constructs an instance of this class.
DBVersionHelper(java.sql.Connection conn)
          Constructs an instance of this class using the given JDBC connection object.
DBVersionHelper(Database db)
          Constructs an instance of this class using the given Database object.
DBVersionHelper(DBVersionHelper other)
          Constructs an instance of this class as a copy of the given instance of this class.
DBVersionHelper(int version, int release, int mod)
          Constructs an instance of this class using the given version, release, and mod level numbers.
DBVersionHelper(ISQLEditorConnectionInfo connInfo)
          Constructs an instance of this class using the given ISQLEditorConnectionInfo object.
DBVersionHelper(java.lang.String versionString)
          Constructs an instance of this class using the given version string.
DBVersionHelper(java.lang.String productFamily, java.lang.String product, int version, int release, int mod)
          Constructs an instance of this class using the given product family, product, version, release, and mod level numbers.
 
Method Summary
 int getMod()
          Gets the mod level.
 java.lang.String getProduct()
          Gets the database product.
 java.lang.String getProductFamily()
          Gets the database product family.
 java.lang.String getProductIDString()
          Gets the database product ID string that was used to determine the product.
 int getRelease()
          Gets the release level.
 int getVersion()
          Gets the version.
 java.lang.String getVersionString()
          Gets the current version string.
 boolean isAtLeast(int version)
          Gets whether or not the version of this database is at least as high as the given version.
 boolean isAtLeast(int version, int release)
          Gets whether or not the version and release of this database is at least as high as the given version and release.
 boolean isAtLeast(int version, int release, int mod)
          Gets whether or not the version, release, and mod level of this database is at least the given version, release, and mod level.
 boolean isAtMost(int version)
          Gets whether or not the version of this database is at most the given version.
 boolean isAtMost(int version, int release)
          Gets whether or not the version and release of this database are at most the given version and release.
 boolean isAtMost(int version, int release, int mod)
          Gets whether or not the version, release, and mod level of this database are at most the given version, release, and mod level.
 boolean isCloudscape()
          Gets whether or not this database is IBM Cloudscape.
 boolean isDB2_390()
          Gets whether or not this database is a DB2 for OS/390.
 boolean isDB2_400()
          Gets whether or not this database is a DB2 for OS/400.
 boolean isDB2_Everyplace()
          Gets whether or not this database is a DB2 Everyplace.
 boolean isDB2_iSeries()
          Gets whether or not the database is DB2 for iSeries.
 boolean isDB2_LUW()
          Gets whether or not this database is a DB2 for Linux/Unix/Windows
 boolean isDB2_UDB()
          Gets whether or not this database is a flavor of DB2 UDB.
 boolean isDB2_VMVSE()
          Gets whether or not this database is DB2 for VM/VSE (SQL/DS).
 boolean isDB2_zOS()
          Gets whether or not this database is DB2 for zOS.
 boolean isDB2()
          Gets whether or not this database is a DB2 of any flavor.
 boolean isDerby()
          Gets whether or not this database is Derby (AKA Cloudscape).
 boolean isExactly(int version)
          Gets whether or not the version of this database is exactly the given version.
 boolean isExactly(int version, int release)
          Gets whether or not the version and release of this database are exactly the given version and release.
 boolean isExactly(int version, int release, int mod)
          Gets whether or not the version, release, and mod level of this database are exactly the given version, release, and mod level.
 boolean isInformix()
          Gets whether or not the database is Informix.
 boolean isMySQL()
          Gets whether or not the database is mySQL.
 boolean isOracle()
          Gets whether or not the database is Oracle.
 boolean isSQLServer()
          Gets whether or not the database is SQL Server.
 boolean isSybase_ASA()
          Gets whether or not the database is Sybase ASA.
 boolean isSybase_ASE()
          Gets whether or not the database is Sybase ASE.
 boolean isSybase()
          Gets whether or not the database is Sybase.
 void setProduct(java.lang.String product)
          Sets the database product to the given value.
 void setProductFamily(java.lang.String family)
          Sets the database product family to the given value.
 void setProductIDString(java.lang.String prodStr)
          Sets the product ID string for this database.
 void setVersionReleaseMod(int version, int release, int mod)
          Sets the product version, release, and mod level to the given values.
 void setVersionString(java.lang.String versionString)
          Sets the current version string to the given string.
 java.lang.String toString()
          Gets the content of this object as a string.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_FAMILY

public static final java.lang.String DEFAULT_FAMILY
See Also:
Constant Field Values

DEFAULT_PRODUCT

public static final java.lang.String DEFAULT_PRODUCT
See Also:
Constant Field Values

DEFAULT_VERSION_STRING

public static final java.lang.String DEFAULT_VERSION_STRING
See Also:
Constant Field Values

FAMILY_CLOUDSCAPE

public static final java.lang.String FAMILY_CLOUDSCAPE
See Also:
Constant Field Values

FAMILY_DB2

public static final java.lang.String FAMILY_DB2
See Also:
Constant Field Values

FAMILY_INFORMIX

public static final java.lang.String FAMILY_INFORMIX
See Also:
Constant Field Values

FAMILY_MYSQL

public static final java.lang.String FAMILY_MYSQL
See Also:
Constant Field Values

FAMILY_ORACLE

public static final java.lang.String FAMILY_ORACLE
See Also:
Constant Field Values

FAMILY_SQL_SERVER

public static final java.lang.String FAMILY_SQL_SERVER
See Also:
Constant Field Values

FAMILY_SYBASE

public static final java.lang.String FAMILY_SYBASE
See Also:
Constant Field Values

PRODUCT_CLOUDSCAPE

public static final java.lang.String PRODUCT_CLOUDSCAPE
See Also:
Constant Field Values

PRODUCT_DB2_EVERYPLACE

public static final java.lang.String PRODUCT_DB2_EVERYPLACE
See Also:
Constant Field Values

PRODUCT_DB2_ISERIES

public static final java.lang.String PRODUCT_DB2_ISERIES
See Also:
Constant Field Values

PRODUCT_DB2_LUW

public static final java.lang.String PRODUCT_DB2_LUW
See Also:
Constant Field Values

PRODUCT_DB2_ZOS

public static final java.lang.String PRODUCT_DB2_ZOS
See Also:
Constant Field Values

PRODUCT_DB2_VMVSE

public static final java.lang.String PRODUCT_DB2_VMVSE
See Also:
Constant Field Values

PRODUCT_DERBY

public static final java.lang.String PRODUCT_DERBY
See Also:
Constant Field Values

PRODUCT_INFORMIX

public static final java.lang.String PRODUCT_INFORMIX
See Also:
Constant Field Values

PRODUCT_MYSQL

public static final java.lang.String PRODUCT_MYSQL
See Also:
Constant Field Values

PRODUCT_ORACLE

public static final java.lang.String PRODUCT_ORACLE
See Also:
Constant Field Values

PRODUCT_SQL_SERVER

public static final java.lang.String PRODUCT_SQL_SERVER
See Also:
Constant Field Values

PRODUCT_SYBASE_ASA

public static final java.lang.String PRODUCT_SYBASE_ASA
See Also:
Constant Field Values

PRODUCT_SYBASE_ASE

public static final java.lang.String PRODUCT_SYBASE_ASE
See Also:
Constant Field Values

ID_DB2

public static final java.lang.String ID_DB2
See Also:
Constant Field Values

ID_DB2_PREFIX

public static final java.lang.String ID_DB2_PREFIX
See Also:
Constant Field Values

ID_DB2_UDB

public static final java.lang.String ID_DB2_UDB
See Also:
Constant Field Values

ID_DB2_UDB_ZSERIES

public static final java.lang.String ID_DB2_UDB_ZSERIES
See Also:
Constant Field Values

ID_AS

public static final java.lang.String ID_AS
See Also:
Constant Field Values

ID_AS400

public static final java.lang.String ID_AS400
See Also:
Constant Field Values

ID_DB2400_SQL

public static final java.lang.String ID_DB2400_SQL
See Also:
Constant Field Values

ID_DB2_UDB_AS400

public static final java.lang.String ID_DB2_UDB_AS400
See Also:
Constant Field Values

ID_DB2_UDB_ISERIES

public static final java.lang.String ID_DB2_UDB_ISERIES
See Also:
Constant Field Values

ID_DB2_EVERYPLACE

public static final java.lang.String ID_DB2_EVERYPLACE
See Also:
Constant Field Values

ID_SQLDS

public static final java.lang.String ID_SQLDS
See Also:
Constant Field Values

ID_WORKSTATION

public static final java.lang.String ID_WORKSTATION
See Also:
Constant Field Values

ID_IBM_CLOUDSCAPE

public static final java.lang.String ID_IBM_CLOUDSCAPE
See Also:
Constant Field Values

ID_APACHE_DERBY

public static final java.lang.String ID_APACHE_DERBY
See Also:
Constant Field Values

ID_DERBY

public static final java.lang.String ID_DERBY
See Also:
Constant Field Values

ID_INFORMIX

public static final java.lang.String ID_INFORMIX
See Also:
Constant Field Values

ID_MYSQL

public static final java.lang.String ID_MYSQL
See Also:
Constant Field Values

ID_ORACLE

public static final java.lang.String ID_ORACLE
See Also:
Constant Field Values

ID_SQL_SERVER

public static final java.lang.String ID_SQL_SERVER
See Also:
Constant Field Values

ID_SYBASE_ASA

public static final java.lang.String ID_SYBASE_ASA
See Also:
Constant Field Values

ID_SYBASE_ASE

public static final java.lang.String ID_SYBASE_ASE
See Also:
Constant Field Values
Constructor Detail

DBVersionHelper

public DBVersionHelper()
Constructs an instance of this class. This is the default constructor. The product name and version strings are set to default values.


DBVersionHelper

public DBVersionHelper(java.sql.Connection conn)
Constructs an instance of this class using the given JDBC connection object.

Parameters:
conn - the JDBC connection to use to get product and version information

DBVersionHelper

public DBVersionHelper(ISQLEditorConnectionInfo connInfo)
Constructs an instance of this class using the given ISQLEditorConnectionInfo object.

Parameters:
connInfo - the connection info object to use to get product and verions information

DBVersionHelper

public DBVersionHelper(Database db)
Constructs an instance of this class using the given Database object.

Parameters:
db - the database object to use to get product and version information

DBVersionHelper

public DBVersionHelper(java.lang.String versionString)
Constructs an instance of this class using the given version string. The database product is set to the defined default.

Parameters:
versionString - the version string to use

DBVersionHelper

public DBVersionHelper(int version,
                       int release,
                       int mod)
Constructs an instance of this class using the given version, release, and mod level numbers. The database product is set to the defined default.

Parameters:
version - the database version
release - the database release
mod - the database mod level

DBVersionHelper

public DBVersionHelper(java.lang.String productFamily,
                       java.lang.String product,
                       int version,
                       int release,
                       int mod)
Constructs an instance of this class using the given product family, product, version, release, and mod level numbers. The family should be one of the FAMILY constants defined in this class (or a subclass) and the product should be one of the PRODUCT constants.

Parameters:
productFamily - the product family to set
product - the database product to set
version - the database version to set
release - the database release to set
mod - the database mod level to set

DBVersionHelper

public DBVersionHelper(DBVersionHelper other)
Constructs an instance of this class as a copy of the given instance of this class.

Parameters:
toCopy - the object to copy
Method Detail

getMod

public int getMod()
Gets the mod level.

Returns:
the mod level for the database

getProductFamily

public java.lang.String getProductFamily()
Gets the database product family. This is one of the FAMILY constants defined in this class (or a subclass).

Returns:
the current database product family constant

getProduct

public java.lang.String getProduct()
Gets the database product. This is one of the PRODUCT constants defined in this class (or a subclass).

Returns:
the current database product constant

getProductIDString

public java.lang.String getProductIDString()
Gets the database product ID string that was used to determine the product. A product ID string is an identifying string for a database product that is returned by Connection.getDatabaseProductName(), DatabaseDefinition.getProduct(), or Database.getVendor().

Returns:
the current product ID string

getRelease

public int getRelease()
Gets the release level.

Returns:
the release level for the database

getVersion

public int getVersion()
Gets the version.

Returns:
the version of the database

getVersionString

public java.lang.String getVersionString()
Gets the current version string. This is the combination of version, release, and modification.

Returns:
the version string

isCloudscape

public boolean isCloudscape()
Gets whether or not this database is IBM Cloudscape.

Returns:
true when the current database is Cloudscape, otherwise false

isDB2

public boolean isDB2()
Gets whether or not this database is a DB2 of any flavor.

Returns:
true when the current database is DB2, otherwise false

isDB2_UDB

public boolean isDB2_UDB()
Gets whether or not this database is a flavor of DB2 UDB. (That is, one of DB2 UDB for iSeries, DB2 UDB for LUW, or DB2 UDB for zOS.)

Returns:
true when the current database is DB2 UDB, otherwise false

isDB2_390

public boolean isDB2_390()
Gets whether or not this database is a DB2 for OS/390. (This is the same as "isDB2_zOS".)

Returns:
true when the current database is DB2 for OS/390 or DB2 for zOS, otherwise false

isDB2_400

public boolean isDB2_400()
Gets whether or not this database is a DB2 for OS/400. (This is the same as "isDB2_iSeries".)

Returns:
true when the current database is DB2 for OS/400, otherwise false

isDB2_Everyplace

public boolean isDB2_Everyplace()
Gets whether or not this database is a DB2 Everyplace.

Returns:
true when the current database is DB2 Everyplace, otherwise false

isDB2_iSeries

public boolean isDB2_iSeries()
Gets whether or not the database is DB2 for iSeries. (This is the same as "isDB2_400".)

Returns:
true when the current database is DB2 for iSeries, otherwise false

isDB2_LUW

public boolean isDB2_LUW()
Gets whether or not this database is a DB2 for Linux/Unix/Windows

Returns:
true when the current database is DB2 for LUW, otherwise false

isDB2_VMVSE

public boolean isDB2_VMVSE()
Gets whether or not this database is DB2 for VM/VSE (SQL/DS).

Returns:
true when the current database is DB2 for VM/VSE, otherwise false

isDB2_zOS

public boolean isDB2_zOS()
Gets whether or not this database is DB2 for zOS. (This is the same as "isDB2_390".)

Returns:
true when the current database is DB2 for zOS, otherwise false

isDerby

public boolean isDerby()
Gets whether or not this database is Derby (AKA Cloudscape).

Returns:
true when the current database is Derby, otherwise false

isInformix

public boolean isInformix()
Gets whether or not the database is Informix.

Returns:
true when the database is Informix, otherwise false

isMySQL

public boolean isMySQL()
Gets whether or not the database is mySQL.

Returns:
true when the database is mySQL, otherwise false

isOracle

public boolean isOracle()
Gets whether or not the database is Oracle.

Returns:
true when the database is Oracle, otherwise false

isSQLServer

public boolean isSQLServer()
Gets whether or not the database is SQL Server.

Returns:
true when the database is SQL Server, otherwise false

isSybase

public boolean isSybase()
Gets whether or not the database is Sybase.

Returns:
true when the database is Sybase, otherwise false

isSybase_ASA

public boolean isSybase_ASA()
Gets whether or not the database is Sybase ASA.

Returns:
true when the database is Sybase ASA, otherwise false

isSybase_ASE

public boolean isSybase_ASE()
Gets whether or not the database is Sybase ASE.

Returns:
true when the database is Sybase ASE, otherwise false

isAtLeast

public boolean isAtLeast(int version)
Gets whether or not the version of this database is at least as high as the given version.

Parameters:
version - the version to check
Returns:
true when the current database version is greater than or equal to the given version, otherwise false

isAtLeast

public boolean isAtLeast(int version,
                         int release)
Gets whether or not the version and release of this database is at least as high as the given version and release.

Parameters:
version - the version to check
release - the release to check
Returns:
true when the current database version and release are greater than or equal to the given version and release, otherwise false

isAtLeast

public boolean isAtLeast(int version,
                         int release,
                         int mod)
Gets whether or not the version, release, and mod level of this database is at least the given version, release, and mod level.

Parameters:
version - the version to check
release - the release to check
mod - the mod level to check
Returns:
true when the current database version, release, and mod level are greater than or equal to the given version, release, and mod level, otherwise false

isAtMost

public boolean isAtMost(int version)
Gets whether or not the version of this database is at most the given version.

Parameters:
version - the version to check
Returns:
true when the current database version is less than or equal to the given version, otherwise false

isAtMost

public boolean isAtMost(int version,
                        int release)
Gets whether or not the version and release of this database are at most the given version and release.

Parameters:
version - the version to check
release - the release to check
Returns:
true when the current database version and release are less than or equal to the given version and release, otherwise false

isAtMost

public boolean isAtMost(int version,
                        int release,
                        int mod)
Gets whether or not the version, release, and mod level of this database are at most the given version, release, and mod level.

Parameters:
version - the version to check
release - the release to check
mod - the mod level to check
Returns:
true when the current database version, release, and mod level are less than or equal to the given version, release, and mod level, otherwise false

isExactly

public boolean isExactly(int version)
Gets whether or not the version of this database is exactly the given version.

Parameters:
version - the version to check
Returns:
true when the current database version is exactly the given version, otherwise false

isExactly

public boolean isExactly(int version,
                         int release)
Gets whether or not the version and release of this database are exactly the given version and release.

Parameters:
version - the version to check
release - the release to check
Returns:
true when the current database version and release are exactly the given version and release, otherwise false

isExactly

public boolean isExactly(int version,
                         int release,
                         int mod)
Gets whether or not the version, release, and mod level of this database are exactly the given version, release, and mod level.

Parameters:
version - the version to check
release - the release to check
mod - the mod level to check
Returns:
true when the current database version, release and mod level are exactly the given version, release, and mod level, otherwise false

setProductFamily

public void setProductFamily(java.lang.String family)
Sets the database product family to the given value. This should be one of the FAMILY constants defined in this class (or a subclass).

Parameters:
family - the product family to set

setProduct

public void setProduct(java.lang.String product)
Sets the database product to the given value. This should be one of the PRODUCT constants defined in this class (or a subclass).

Parameters:
product - the product to set

setProductIDString

public void setProductIDString(java.lang.String prodStr)
Sets the product ID string for this database. A product ID string is an identifying string for a database product that is returned by Connection.getDatabaseProductName(), DatabaseDefinition.getProduct(), or Database.getVendor(). They are used to determine the database product and family.

Parameters:
prodStr - the product ID string to set

setVersionString

public void setVersionString(java.lang.String versionString)
Sets the current version string to the given string. The version string includes the version, release, and modification (ie, "7.1.0"); The string is parsed to set the numeric version, release, and mod level values.

Parameters:
versionString - the version string to set

setVersionReleaseMod

public void setVersionReleaseMod(int version,
                                 int release,
                                 int mod)
Sets the product version, release, and mod level to the given values. This method also sets the version string to match the values.

Parameters:
version - the version
release - the release
the - mod level

toString

public java.lang.String toString()
Gets the content of this object as a string.

Overrides:
toString in class java.lang.Object
Returns:
the string version of this object