001: /*
002: * This file is part of the QuickServer library
003: * Copyright (C) 2003-2005 QuickServer.org
004: *
005: * Use, modification, copying and distribution of this software is subject to
006: * the terms and conditions of the GNU Lesser General Public License.
007: * You should have received a copy of the GNU LGP License along with this
008: * library; if not, you can download a copy from <http://www.quickserver.org/>.
009: *
010: * For questions, suggestions, bug-reports, enhancement-requests etc.
011: * visit http://www.quickserver.org
012: *
013: */
014:
015: package org.quickserver.util.xmlreader;
016:
017: import org.quickserver.net.server.QuickServer;
018:
019: /**
020: * This class encapsulate the database connection configuration.
021: * The xml is <database-connection>...</database-connection>
022: * @author Akshathkumar Shetty
023: * @since 1.3
024: */
025: public class DatabaseConnectionConfig implements java.io.Serializable {
026: private String id = "";
027: private String driver = "";
028: private String url = "";
029: private String username = "";
030: private String password = "";
031:
032: /**
033: * Returns the id.
034: * @return id that identifies the connection.
035: */
036: public String getId() {
037: return id;
038: }
039:
040: /**
041: * Sets the id.
042: * XML Tag: <id></id>
043: * @param id for this connection.
044: */
045: public void setId(String id) {
046: if (id != null)
047: this .id = id;
048: }
049:
050: /**
051: * Returns the database driver.
052: * @return driver that driver class
053: */
054: public String getDriver() {
055: return driver;
056: }
057:
058: /**
059: * Sets the database driver.
060: * XML Tag: <driver></driver>
061: * @param driver that driver class
062: */
063: public void setDriver(String driver) {
064: if (driver != null)
065: this .driver = driver;
066: }
067:
068: /**
069: * Returns the url.
070: * @return URl for this connection.
071: */
072: public String getUrl() {
073: return url;
074: }
075:
076: /**
077: * Sets the url.
078: * XML Tag: <url></url>
079: * @param url for this connection.
080: */
081: public void setUrl(String url) {
082: if (url != null)
083: this .url = url;
084: }
085:
086: /**
087: * Returns the username
088: * @return username for this connection.
089: */
090: public String getUsername() {
091: return username;
092: }
093:
094: /**
095: * Sets the username.
096: * XML Tag: <username></username>
097: * @param username for this connection.
098: */
099: public void setUsername(String username) {
100: if (username != null)
101: this .username = username;
102: }
103:
104: /**
105: * Returns the password.
106: * @return password for this connection.
107: */
108: public String getPassword() {
109: return password;
110: }
111:
112: /**
113: * Sets the password.
114: * XML Tag: <password></password>
115: * @param password for this connection.
116: */
117: public void setPassword(String password) {
118: if (password != null)
119: this .password = password;
120: }
121:
122: /**
123: * Returns XML config of this class.
124: * @since 1.3
125: */
126: public String toXML(String pad) {
127: if (pad == null)
128: pad = "";
129: StringBuffer sb = new StringBuffer();
130: sb.append(pad + "<database-connection>\n");
131: sb.append(pad + "\t<id>" + getId() + "</id>\n");
132: sb.append(pad + "\t<driver>" + getDriver() + "</driver>\n");
133: sb.append(pad + "\t<url>" + getUrl() + "</url>\n");
134: sb.append(pad + "\t<username>" + getUsername()
135: + "</username>\n");
136: sb.append(pad + "\t<password>" + getPassword()
137: + "</password>\n");
138: sb.append(pad + "</database-connection>\n");
139: return sb.toString();
140: }
141: }
|