001: /*
002: * Created on 8-Jul-2004
003: *
004: * TODO To change the template for this generated file go to
005: * Window - Preferences - Java - Code Style - Code Templates
006: */
007: package com.pk;
008:
009: /**
010: * @author ctaylor
011: *
012: * TODO To change the template for this generated type comment go to Window -
013: * Preferences - Java - Code Style - Code Templates
014: */
015: public class ConnectionConfig implements Comparable {
016:
017: private String name;
018:
019: private String driver;
020:
021: private String url;
022:
023: private String databaseDialectName;
024:
025: private DatabaseDialect databaseDialect;
026:
027: /**
028: * @return Returns the databaseDilectName.
029: */
030: public String getDatabaseDialectName() {
031: return databaseDialectName;
032: }
033:
034: /**
035: * @param databaseDilectName
036: * The databaseDilectName to set.
037: */
038: public void setDatabaseDialectName(String databaseDilectName) {
039: this .databaseDialectName = databaseDilectName;
040: }
041:
042: /**
043: * @return Returns the driver.
044: */
045: public String getDriver() {
046: return driver;
047: }
048:
049: /**
050: * @param driver
051: * The driver to set.
052: */
053: public void setDriver(String driver) {
054: this .driver = driver;
055: }
056:
057: /**
058: * @return Returns the name.
059: */
060: public String getName() {
061: return name;
062: }
063:
064: /**
065: * @param name
066: * The name to set.
067: */
068: public void setName(String name) {
069: this .name = name;
070: }
071:
072: /**
073: * @return Returns the url.
074: */
075: public String getUrl() {
076: return url;
077: }
078:
079: /**
080: * @param url
081: * The url to set.
082: */
083: public void setUrl(String url) {
084: this .url = url;
085: }
086:
087: /*
088: * (non-Javadoc)
089: *
090: * @see java.lang.Object#toString()
091: */
092: public String toString() {
093: return getName();
094: }
095:
096: /**
097: * @return Returns the databaseDialect.
098: */
099: public DatabaseDialect getDatabaseDialect() {
100: if (databaseDialect == null) {
101: try {
102: databaseDialect = (DatabaseDialect) this .getClass()
103: .getClassLoader()
104: .loadClass(databaseDialectName).newInstance();
105: } catch (Exception e) {
106: //TODO display error when class not found.
107: e.printStackTrace();
108: }
109: }
110: return databaseDialect;
111: }
112:
113: /* (non-Javadoc)
114: * @see java.lang.Comparable#compareTo(java.lang.Object)
115: */
116: public int compareTo(Object arg0) {
117: ConnectionConfig tmp = (ConnectionConfig) arg0;
118: return name.compareToIgnoreCase(tmp.getName());
119: }
120: }
|