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