KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.util.*;
18 /**
19  * This class encapsulate the database connection set.
20  * The xml is &lt;database-connection-set&gt;...&lt;/database-connection-set&gt;
21  * @author Akshathkumar Shetty
22  * @since 1.3
23  */

24 public class DatabaseConnectionSet implements java.io.Serializable JavaDoc {
25     private ArrayList databaseConnectionSet=null;
26     
27     public DatabaseConnectionSet() {
28         databaseConnectionSet = new ArrayList();
29     }
30
31     /**
32      * Adds a DatabaseConnectionConfig object to the set.
33      */

34     public void addDatabaseConnection(DatabaseConnectionConfig dbcConfig) {
35         if(dbcConfig!=null) {
36             databaseConnectionSet.add(dbcConfig);
37         }
38     }
39
40     public Iterator iterator() {
41         return databaseConnectionSet.iterator();
42     }
43
44     /**
45      * Returns XML config of this class.
46      * @since 1.3
47      */

48     public String JavaDoc toXML(String JavaDoc pad) {
49         if(pad==null) pad="";
50         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
51         sb.append(pad+"<database-connection-set>\n");
52         Iterator iterator = iterator();
53         while(iterator.hasNext()) {
54             DatabaseConnectionConfig dcc =
55                 (DatabaseConnectionConfig)iterator.next();
56             sb.append(dcc.toXML(pad+"\t"));
57         }
58         sb.append(pad+"</database-connection-set>\n");
59         return sb.toString();
60     }
61 }
62
Popular Tags