Copyright 2009,2010, Lapetus Systems Ltd. (All rights reserved)

com.lapetus_ltd.api.db.xml.types
Class TLptsDriverLoaderType

java.lang.Object
  extended by com.lapetus_ltd._2009.xml.types.XLptsDriverLoaderType
      extended by com.lapetus_ltd.api.db.xml.types.TLptsDriverLoaderType

public class TLptsDriverLoaderType
extends XLptsDriverLoaderType

Class Description : This class holds the driver information for the driver loader.

It is the data class of the Driver Loader capability, and is used by TLptsDriverLoader for storing all the
information for the drivers and their interfaces. The functions and parameters are stored here for every
driver that is to be used in dbJAPI for connection purposes.
The drivers are dynamically loaded, along with their functional interfaces. The interfaces are then used by
the GUI for processing the parameters from the user for the connection.

$LastChangedRevision: 1190 $
$LastChangedDate:: 2010-11-17 13:21:35#$


Field Summary
 
Fields inherited from class com.lapetus_ltd._2009.xml.types.XLptsDriverLoaderType
defaultCharSet, driverListItem, id, title, version
 
Constructor Summary
TLptsDriverLoaderType()
           This constructs an empty TLptsDriverLoaderType.
TLptsDriverLoaderType(XLptsDriverLoaderType driverLoaderType)
           This constructs a XLptsDriverLoaderType, which is a copy of another.
 
Method Summary
 void addDriverListItem(XLptsDriverType driverType)
           Adds a driver to the driver list.
 boolean equals(java.lang.Object obj)
           Check for equal TLptsDriverLoaderType objects.
 java.util.List<XLptsDriverType> getDriverListItem()
           Returns a synchronised copy of the driver list.
 int getDriverListItemSize()
           Returns the size of the actual list.
 void initialise(XLptsDriverLoaderType driverLoaderType)
           Initialises this XLptsDriverLoaderType class with all the values from another XLptsDriverLoaderType.
 void removeDriverListItem(XLptsDriverType driverType)
           Removes a driver to the driver list.
 
Methods inherited from class com.lapetus_ltd._2009.xml.types.XLptsDriverLoaderType
getDefaultCharSet, getId, getTitle, getVersion, setDefaultCharSet, setId, setTitle, setVersion
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TLptsDriverLoaderType

public TLptsDriverLoaderType()

This constructs an empty TLptsDriverLoaderType.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : Never.

Notes : Default Constructor set a new id, title as "Driver Loader Info" and version as "1.0". Also creates a new driver list.

Example :

 

TLptsDriverLoaderType driverLoaderType = new TLptsDriverLoaderType(); TLptsDriverType driverItem = new TLptsDriverType(); driverItem.setTitle("MS SQL DataSource Driver"); ... driverLoaderType.addDriverListItem(driverItem); ObjectFactory of1 = new ObjectFactory(); TLptsXmlUtil.marshal("driver.loader.xml",XLptsDriverLoaderType.class,of1.createXLptsDriverLoaderType(driverLoaderType));


TLptsDriverLoaderType

public TLptsDriverLoaderType(XLptsDriverLoaderType driverLoaderType)

This constructs a XLptsDriverLoaderType, which is a copy of another.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : Never.

Notes : Use this Constructor to set TLptsDriverLoaderType from another XLptsDriverLoaderType"

Example :

 //Load from file
 XLptsDriverLoaderType dlt = (XLptsDriverLoaderType) TLptsXmlUtil.unmarshal("driver.loader.xml",XLptsDriverLoaderType.class);
 TLptsDriverLoaderType driverLoaderTypeLoad =  new TLptsDriverLoaderType(dlt);
 ...
 

Parameters:
driverLoaderType - The driver loader type to copy.
Method Detail

addDriverListItem

public void addDriverListItem(XLptsDriverType driverType)

Adds a driver to the driver list.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : n/a

Notes : Use this and not the getDriverListItem().add() function.

Example :

 

TLptsDriverLoaderType driverLoaderType = new TLptsDriverLoaderType(); TLptsDriverType driverItem = new TLptsDriverType(); driverItem.setTitle("MS SQL DataSource Driver"); ... driverLoaderType.addDriverListItem(driverItem);

Parameters:
driverType - the driver type to add in the list.

equals

public boolean equals(java.lang.Object obj)

Check for equal TLptsDriverLoaderType objects.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : n/a

Notes : Use this to compare two TLptsDriverLoaderType objects by there id.

Example :

 

TLptsDriverLoaderType dlt1 = new TLptsDriverLoaderType(); TLptsDriverLoaderType dlt2 = new TLptsDriverLoaderType(); return dlt1.equals(dlt2);

Result: false, because each TLptsDriverLoaderType has each own unique id.

Overrides:
equals in class java.lang.Object
Parameters:
obj - the driver loader type
Returns:
true if they are equal, else false.

getDriverListItem

public java.util.List<XLptsDriverType> getDriverListItem()

Returns a synchronised copy of the driver list.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : Never. In the worst case an empty list is returned.

Notes : Never add to or remove from this list and there is not affect to the driver list.

Example :

 if(driverLoaderType.getDriverListItemSize()>0)
 {
    for (XLptsDriverType dlit : driverLoaderType.getDriverListItem())
    {
      if (!isSupportedOnOS(dlit))
      {
        driverLoaderType.removeDriverListItem(dlit);
        break;
      }
    }
 }
 else
    TLptsLogger.logMessage("Driver List Size is zero",null);
 ...
 

private boolean isSupportedOnOS(XLptsDriverType driverType) { TLptsDriverType dt = new TLptsDriverType(driverType);

for (XLptsOperatingSystemType ost : dt.getOperatingSystemListItem()) { if (ost.equals(XLptsOperatingSystemType.WINDOWS)) if (TLptsSysInfoUtil.isHostWindows()) return true; } return false; }

Overrides:
getDriverListItem in class XLptsDriverLoaderType
Returns:
Returns a synchronised list copy of the driver list.

getDriverListItemSize

public int getDriverListItemSize()

Returns the size of the actual list.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : Never. The result may be an empty list.

Notes : Do not use getDriverListItem().size() as it is not efficient.

Example :

 if(driverLoaderType.getDriverListItemSize()>0)
 {
    for (XLptsDriverType dlit : driverLoaderType.getDriverListItem())
    {
      if (!isSupportedOnOS(dlit))
      {
        driverLoaderType.removeDriverListItem(dlit);
        break;
      }
    }
 }
 else
    TLptsLogger.logMessage("Driver List Size is zero",null);
 ...
 

private boolean isSupportedOnOS(XLptsDriverType driverType) { TLptsDriverType dt = new TLptsDriverType(driverType);

for (XLptsOperatingSystemType ost : dt.getOperatingSystemListItem()) { if (ost.equals(XLptsOperatingSystemType.WINDOWS)) if (TLptsSysInfoUtil.isHostWindows()) return true; } return false; }

Returns:
Returns the number of connections.

initialise

public void initialise(XLptsDriverLoaderType driverLoaderType)

Initialises this XLptsDriverLoaderType class with all the values from another XLptsDriverLoaderType.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : n/a

Notes : It is used by the driver loader to initialise the driver loader from the xml config file.

Example :

 

XLptsDriverLoaderType dlt = (XLptsDriverLoaderType) TLptsXmlUtil.unmarshal(driverLoaderUrlOrFile, XLptsDriverLoaderType.class); TLptsDriverLoaderType driverLoaderType = new TLptsDriverLoaderType(); driverLoaderType.initialise(dlt); //Or //TLptsDriverLoaderType driverLoaderType = new TLptsDriverLoaderType(dlt);

Parameters:
driverLoaderType - The driver loader type to use for initialising this class.

removeDriverListItem

public void removeDriverListItem(XLptsDriverType driverType)

Removes a driver to the driver list.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : n/a

Notes : Use this and not the getDriverListItem().remove() function.

Example :

 if(driverLoaderType.getDriverListItemSize()>0)
 {
    for (XLptsDriverType dlit : driverLoaderType.getDriverListItem())
    {
      if (!isSupportedOnOS(dlit))
      {
        driverLoaderType.removeDriverListItem(dlit);
        break;
      }
    }
 }
 else
    TLptsLogger.logMessage("Driver List Size is zero",null);
 ...
 

private boolean isSupportedOnOS(XLptsDriverType driverType) { TLptsDriverType dt = new TLptsDriverType(driverType);

for (XLptsOperatingSystemType ost : dt.getOperatingSystemListItem()) { if (ost.equals(XLptsOperatingSystemType.WINDOWS)) if (TLptsSysInfoUtil.isHostWindows()) return true; } return false; }

Parameters:
driverType - the driver type to remove from driver list


Copyright 2009,2010, Lapetus Systems Ltd. (All rights reserved)