KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > quickserver > util > xmlreader > DatabaseConnectionConfig


1 /*
2  * This file is part of the QuickServer library
3  * Copyright (C) 2003-2005 QuickServer.org
4  *
5  * Use, modification, copying and distribution of this software is subject to
6  * the terms and conditions of the GNU Lesser General Public License.
7  * You should have received a copy of the GNU LGP License along with this
8  * library; if not, you can download a copy from <http://www.quickserver.org/>.
9  *
10  * For questions, suggestions, bug-reports, enhancement-requests etc.
11  * visit http://www.quickserver.org
12  *
13  */

14
15 package org.quickserver.util.xmlreader;
16
17 import org.quickserver.net.server.QuickServer;
18 /**
19  * This class encapsulate the database connection configuration.
20  * The xml is &lt;database-connection&gt;...&lt;/database-connection&gt;
21  * @author Akshathkumar Shetty
22  * @since 1.3
23  */

24 public class DatabaseConnectionConfig implements java.io.Serializable JavaDoc {
25     private String JavaDoc id = "";
26     private String JavaDoc driver = "";
27     private String JavaDoc url = "";
28     private String JavaDoc username = "";
29     private String JavaDoc password = "";
30
31     /**
32      * Returns the id.
33      * @return id that identifies the connection.
34      */

35     public String JavaDoc getId() {
36         return id;
37     }
38     /**
39      * Sets the id.
40      * XML Tag: &lt;id&gt;&lt;/id&gt;
41      * @param id for this connection.
42      */

43     public void setId(String JavaDoc id) {
44         if(id!=null)
45             this.id = id;
46     }
47
48     /**
49      * Returns the database driver.
50      * @return driver that driver class
51      */

52     public String JavaDoc getDriver() {
53         return driver;
54     }
55     /**
56      * Sets the database driver.
57      * XML Tag: &lt;driver&gt;&lt;/driver&gt;
58      * @param driver that driver class
59      */

60     public void setDriver(String JavaDoc driver) {
61         if(driver!=null)
62             this.driver = driver;
63     }
64
65     /**
66      * Returns the url.
67      * @return URl for this connection.
68      */

69     public String JavaDoc getUrl() {
70         return url;
71     }
72     /**
73      * Sets the url.
74      * XML Tag: &lt;url&gt;&lt;/url&gt;
75      * @param url for this connection.
76      */

77     public void setUrl(String JavaDoc url) {
78         if(url!=null)
79             this.url = url;
80     }
81
82     /**
83      * Returns the username
84      * @return username for this connection.
85      */

86     public String JavaDoc getUsername() {
87         return username;
88     }
89     /**
90      * Sets the username.
91      * XML Tag: &lt;username&gt;&lt;/username&gt;
92      * @param username for this connection.
93      */

94     public void setUsername(String JavaDoc username) {
95         if(username!=null)
96             this.username = username;
97     }
98
99     /**
100      * Returns the password.
101      * @return password for this connection.
102      */

103     public String JavaDoc getPassword() {
104         return password;
105     }
106     /**
107      * Sets the password.
108      * XML Tag: &lt;password&gt;&lt;/password&gt;
109      * @param password for this connection.
110      */

111     public void setPassword(String JavaDoc password) {
112         if(password!=null)
113             this.password = password;
114     }
115
116     /**
117      * Returns XML config of this class.
118      * @since 1.3
119      */

120     public String JavaDoc toXML(String JavaDoc pad) {
121         if(pad==null) pad="";
122         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
123         sb.append(pad+"<database-connection>\n");
124         sb.append(pad+"\t<id>"+getId()+"</id>\n");
125         sb.append(pad+"\t<driver>"+getDriver()+"</driver>\n");
126         sb.append(pad+"\t<url>"+getUrl()+"</url>\n");
127         sb.append(pad+"\t<username>"+getUsername()+"</username>\n");
128         sb.append(pad+"\t<password>"+getPassword()+"</password>\n");
129         sb.append(pad+"</database-connection>\n");
130         return sb.toString();
131     }
132 }
133
Popular Tags