1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.betwixt.digester;
18
19
20 import org.apache.commons.logging.Log;
21 import org.apache.commons.logging.LogFactory;
22 import org.xml.sax.Attributes;
23 import org.xml.sax.SAXException;
24
25 /***
26 * Digester Rule to process config elements.
27 * @since 0.7
28 * @author Brian Pugh
29 */
30 public class ConfigRule extends RuleSupport {
31 /*** Logger. */
32 private static final Log log = LogFactory.getLog(ConfigRule.class);
33
34 /*** Base constructor. */
35 public ConfigRule() {
36 }
37
38
39 /***
40 * Process the beginning of this element.
41 *
42 * @param attributes The attribute list of this element
43 * @throws org.xml.sax.SAXException if the primitiveTypes attribute contains an invalid value
44 */
45 public void begin(Attributes attributes) throws SAXException {
46 String value = attributes.getValue("primitiveTypes");
47 if (value != null) {
48 if (value.equalsIgnoreCase("element")) {
49 getXMLInfoDigester().setAttributesForPrimitives(false);
50
51 } else if (value.equalsIgnoreCase("attribute")) {
52 getXMLInfoDigester().setAttributesForPrimitives(true);
53 } else {
54 throw new SAXException(
55 "Invalid value inside element <betwixt-config> for attribute 'primitiveTypes'."
56 + " Value should be 'element' or 'attribute'");
57 }
58 }
59 MultiMappingBeanInfoDigester digester = (MultiMappingBeanInfoDigester) getDigester();
60 getDigester().push(digester.getBeanInfoMap());
61 }
62 /***
63 * Process the end of this element.
64 */
65 public void end() {
66 Object top = getDigester().pop();
67 }
68
69
70 }