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 import org.apache.commons.betwixt.XMLBeanInfo;
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
27
28
29
30 public class InfoRule extends RuleSupport {
31
32
33 private static final Log log = LogFactory.getLog( InfoRule.class );
34
35 private XMLBeanInfo xmlBeanInfo;
36
37
38 public InfoRule() {
39 }
40
41
42
43
44
45
46
47
48
49
50 public void begin(String name, String namespace, Attributes attributes) throws SAXException {
51 Class beanClass = getBeanClass();
52
53 xmlBeanInfo = new XMLBeanInfo( beanClass );
54
55 String value = attributes.getValue( "primitiveTypes" );
56 if ( value != null ) {
57 if ( value.equalsIgnoreCase( "element" ) ) {
58 getXMLInfoDigester().setAttributesForPrimitives( false );
59
60 } else if ( value.equalsIgnoreCase( "attribute" ) ) {
61 getXMLInfoDigester().setAttributesForPrimitives( true );
62
63 } else {
64 throw new SAXException(
65 "Invalid value inside element <info> for attribute 'primitiveTypes'."
66 + " Value should be 'element' or 'attribute'" );
67 }
68 }
69
70 getDigester().push(xmlBeanInfo);
71 }
72
73
74
75
76
77 public void end(String name, String namespace) {
78 Object top = getDigester().pop();
79 }
80 }