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