2009/05/20 - Apache Shale has been retired.
For more information, please explore the Attic.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.shale.tiger.managed.rules;
19
20 import org.apache.commons.digester.Rule;
21 import org.apache.shale.tiger.managed.config.ListEntriesConfig;
22 import org.apache.shale.tiger.managed.config.ListEntryConfig;
23 import org.xml.sax.Attributes;
24
25 /***
26 * <p>Digester rule for processing a <code><list-entries></code>
27 * nested element.</p>
28 */
29 public class ListEntryRule extends Rule {
30
31 /*** Creates a new instance of ListEntryRule. */
32 public ListEntryRule() {
33 }
34
35 /*** <p>Fully qualified class name of our configuration element bean.</p> */
36 private static final String CLASS_NAME =
37 "org.apache.shale.tiger.managed.config.ListEntryConfig";
38
39 /***
40 * <p>Create a new {@link ListEntryConfig} and push it on to the
41 * Digester stack.</p>
42 *
43 * @param namespace Namespace URI of the matching element
44 * @param name Local name of the matching element
45 * @param attributes Attribute list of the matching element
46 *
47 * @exception Exception if a parsing error occurs
48 */
49 public void begin(String namespace, String name,
50 Attributes attributes) throws Exception {
51
52 Class clazz = digester.getClassLoader().loadClass(CLASS_NAME);
53 digester.push(clazz.newInstance());
54
55 }
56
57
58 /***
59 * <p>No body processing for this element.</p>
60 *
61 * @param namespace Namespace URI of the matching element
62 * @param name Local name of the matching element
63 *
64 * @throws Exception if a parsing error occurs
65 */
66 public void body(String namespace, String name) throws Exception {
67 }
68
69
70 /***
71 * <p>Pop the {@link ListEntryConfig} instance from the stack,
72 * and either add it to the parent configuration.</p>
73 *
74 * @param namespace Namespace URI of the matching element
75 * @param name Local name of the matching element
76 *
77 * @exception IllegalStateException if the popped object is not
78 * of the correct type
79 * @exception Exception if a different error occurs
80 */
81 public void end(String namespace, String name) throws Exception {
82
83 ListEntryConfig config = (ListEntryConfig) digester.pop();
84 ListEntriesConfig parent = (ListEntriesConfig) digester.peek();
85 parent.addEntry(config);
86
87 }
88
89
90 }