1 22 package org.jboss.kernel.plugins.deployment.xml; 23 24 import javax.xml.namespace.NamespaceContext ; 25 import javax.xml.namespace.QName ; 26 27 import org.jboss.beans.metadata.plugins.AbstractPropertyMetaData; 28 import org.jboss.beans.metadata.plugins.StringValueMetaData; 29 import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementHandler; 30 import org.jboss.xb.binding.sunday.unmarshalling.ElementBinding; 31 import org.xml.sax.Attributes ; 32 33 39 public class PropertyHandler extends DefaultElementHandler 40 { 41 42 public static final PropertyHandler HANDLER = new PropertyHandler(); 43 44 public Object startElement(Object parent, QName name, ElementBinding element) 45 { 46 return new AbstractPropertyMetaData(); 47 } 48 49 public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx) 50 { 51 AbstractPropertyMetaData property = (AbstractPropertyMetaData) o; 52 for (int i = 0; i < attrs.getLength(); ++i) 53 { 54 String localName = attrs.getLocalName(i); 55 if ("name".equals(localName)) 56 property.setName(attrs.getValue(i)); 57 else if ("class".equals(localName)) 58 { 59 StringValueMetaData svmd = new StringValueMetaData(); 60 svmd.setType(attrs.getValue(i)); 61 property.setValue(svmd); 62 } 63 } 64 } 65 66 public Object endElement(Object o, QName qName, ElementBinding element) 67 { 68 AbstractPropertyMetaData x = (AbstractPropertyMetaData) o; 69 String name = x.getName(); 70 if (name == null || name.trim().length() == 0) 71 throw new IllegalArgumentException ("Null or empty property name."); 72 return o; 73 } 74 } 75 | Popular Tags |