01: /*
02: * This file is part of the QuickServer library
03: * Copyright (C) 2003-2005 QuickServer.org
04: *
05: * Use, modification, copying and distribution of this software is subject to
06: * the terms and conditions of the GNU Lesser General Public License.
07: * You should have received a copy of the GNU LGP License along with this
08: * library; if not, you can download a copy from <http://www.quickserver.org/>.
09: *
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: /**
20: * This class encapsulate the database connection set.
21: * The xml is <database-connection-set>...</database-connection-set>
22: * @author Akshathkumar Shetty
23: * @since 1.3
24: */
25: public class DatabaseConnectionSet implements java.io.Serializable {
26: private ArrayList databaseConnectionSet = null;
27:
28: public DatabaseConnectionSet() {
29: databaseConnectionSet = new ArrayList();
30: }
31:
32: /**
33: * Adds a DatabaseConnectionConfig object to the set.
34: */
35: public void addDatabaseConnection(DatabaseConnectionConfig dbcConfig) {
36: if (dbcConfig != null) {
37: databaseConnectionSet.add(dbcConfig);
38: }
39: }
40:
41: public Iterator iterator() {
42: return databaseConnectionSet.iterator();
43: }
44:
45: /**
46: * Returns XML config of this class.
47: * @since 1.3
48: */
49: public String toXML(String pad) {
50: if (pad == null)
51: pad = "";
52: StringBuffer sb = new StringBuffer();
53: sb.append(pad + "<database-connection-set>\n");
54: Iterator iterator = iterator();
55: while (iterator.hasNext()) {
56: DatabaseConnectionConfig dcc = (DatabaseConnectionConfig) iterator
57: .next();
58: sb.append(dcc.toXML(pad + "\t"));
59: }
60: sb.append(pad + "</database-connection-set>\n");
61: return sb.toString();
62: }
63: }
|