1 22 package org.jboss.test.xml.initializer; 23 24 import javax.xml.namespace.QName ; 25 26 import org.jboss.xb.binding.metadata.ClassMetaData; 27 import org.jboss.xb.binding.metadata.PropertyMetaData; 28 import org.jboss.xb.binding.sunday.unmarshalling.DefaultWildcardHandler; 29 import org.jboss.xb.binding.sunday.unmarshalling.ElementBinding; 30 import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding; 31 import org.jboss.xb.binding.sunday.unmarshalling.SchemaBindingInitializer; 32 33 39 public class ContainerInitializer implements SchemaBindingInitializer 40 { 41 public static final String NS = "dummy://www.jboss.org/container"; 42 43 private static final QName containerStrictQName = new QName (NS, "containerStrict"); 44 private static final QName containerLaxQName = new QName (NS, "containerLax"); 45 private static final QName containerSkipQName = new QName (NS, "containerSkip"); 46 47 private static final ContainerWildcardHandler wildcardHandler = new ContainerWildcardHandler(); 48 49 public SchemaBinding init(SchemaBinding schema) 50 { 51 ClassMetaData classMetaData = new ClassMetaData(); 52 classMetaData.setImpl(Container.class.getName()); 53 54 PropertyMetaData property = new PropertyMetaData(); 55 property.setName("value"); 56 57 ElementBinding containerStrict = schema.getElement(containerStrictQName); 58 containerStrict.setClassMetaData(classMetaData); 59 containerStrict.getType().getWildcard().setWildcardHandler(wildcardHandler); 60 ElementBinding containerLax = schema.getElement(containerLaxQName); 61 containerLax.setClassMetaData(classMetaData); 62 containerStrict.getType().getWildcard().setWildcardHandler(wildcardHandler); 63 ElementBinding containerSkip = schema.getElement(containerSkipQName); 64 containerSkip.setClassMetaData(classMetaData); 65 containerStrict.getType().getWildcard().setWildcardHandler(wildcardHandler); 66 67 return schema; 68 } 69 70 private static class ContainerWildcardHandler extends DefaultWildcardHandler 71 { 72 public void setParent(Object parent, Object o, QName elementName, ElementBinding element, ElementBinding parentElement) 73 { 74 Container container = (Container) parent; 75 container.setValue(o); 76 } 77 } 78 } 79 | Popular Tags |