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 Server Hooks. These are event listeners to
21: * the QuickServer.
22: * The example xml is <pre>
23: ....
24: <server-hooks>
25: <class-name>package1.Class1</class-name>
26: <class-name>package1.Class2</class-name>
27: </server-hooks>
28: ....
29: </pre>
30: * @see org.quickserver.net.ServerHook
31: * @see org.quickserver.util.xmlreader.InitServerHooks
32: * @author Akshathkumar Shetty
33: * @since 1.3.3
34: */
35: public class ServerHooks extends ArrayList {
36:
37: /**
38: * Addes the class to server hooks
39: */
40: public void addClassName(String className) {
41: if (className != null && className.trim().length() != 0) {
42: add(className.trim());
43: }
44: }
45:
46: /**
47: * Returns XML config of this class.
48: */
49: public String toXML(String pad) {
50: if (pad == null)
51: pad = "";
52: StringBuffer sb = new StringBuffer();
53: sb.append(pad + "<server-hooks>\n");
54: Iterator iterator = iterator();
55: while (iterator.hasNext()) {
56: String classname = (String) iterator.next();
57: sb.append(pad + "\t<class-name>" + classname
58: + "</class-name>\n");
59: }
60: sb.append(pad + "</server-hooks>\n");
61: return sb.toString();
62: }
63: }
|