1 7 package org.jboss.test.xml.multispaced; 8 9 import org.jboss.xb.binding.ObjectModelFactory; 10 import org.jboss.xb.binding.UnmarshallingContext; 11 import org.xml.sax.Attributes ; 12 13 17 public class XMBeanMetaDataFactory 18 implements ObjectModelFactory 19 { 20 public static final XMBeanMetaDataFactory INSTANCE = new XMBeanMetaDataFactory(); 21 22 private XMBeanMetaDataFactory() 23 { 24 } 25 26 public Object completeRoot(Object root, UnmarshallingContext ctx, 27 String uri, String name) 28 { 29 return root; 30 } 31 32 public Object newRoot(Object root, 33 UnmarshallingContext navigator, 34 String namespaceURI, 35 String localName, 36 Attributes attrs) 37 { 38 return root == null ? new XMBeanMetaData() : root; 39 } 40 41 public void setValue(XMBeanMetaData xmbean, 42 UnmarshallingContext navigator, 43 String namespaceUri, 44 String localName, 45 String value) 46 { 47 if("description".equals(localName)) 48 { 49 xmbean.setDescription(value); 50 } 51 else if("class".equals(localName)) 52 { 53 xmbean.setMbeanClass(value); 54 } 55 } 56 57 public Object newChild(XMBeanMetaData xmbean, 58 UnmarshallingContext navigator, 59 String namespaceUri, 60 String localName, 61 Attributes attrs) 62 { 63 Object child; 64 if("constructor".equals(localName)) 65 { 66 child = new XMBeanConstructorMetaData(); 67 } 68 else if("attribute".equals(localName)) 69 { 70 final XMBeanAttributeMetaData attribute = new XMBeanAttributeMetaData(); 71 for(int i = 0; i < attrs.getLength(); ++i) 72 { 73 final String attrName = attrs.getLocalName(i); 74 if("access".equals(attrName)) 75 { 76 attribute.setAccess(attrs.getValue(i)); 77 } 78 else if("getMethod".equals(attrName)) 79 { 80 attribute.setGetMethod(attrs.getValue(i)); 81 } 82 else if("setMethod".equals(attrName)) 83 { 84 attribute.setSetMethod(attrs.getValue(i)); 85 } 86 } 87 child = attribute; 88 } 89 else if("operation".equals(localName)) 90 { 91 child = new XMBeanOperationMetaData(); 92 } 93 else if("notification".equals(localName)) 94 { 95 child = new XMBeanNotificationMetaData(); 96 } 97 else 98 { 99 child = null; 100 } 101 102 return child; 103 } 104 105 public void addChild(XMBeanMetaData xmbean, XMBeanConstructorMetaData constructor, UnmarshallingContext navigator, String namespaceURI, String localName) 106 { 107 xmbean.addConstructor(constructor); 108 } 109 110 public void addChild(XMBeanMetaData xmbean, XMBeanAttributeMetaData attribute, UnmarshallingContext navigator, String namespaceURI, String localName) 111 { 112 xmbean.addAttribute(attribute); 113 } 114 115 public void addChild(XMBeanMetaData xmbean, XMBeanOperationMetaData operation, UnmarshallingContext navigator, String namespaceURI, String localName) 116 { 117 xmbean.addOperation(operation); 118 } 119 120 public void addChild(XMBeanMetaData xmbean, XMBeanNotificationMetaData notification, UnmarshallingContext navigator, String namespaceURI, String localName) 121 { 122 xmbean.addNotification(notification); 123 } 124 125 public void addChild(XMBeanMetaData xmbean, 126 Object pm, 127 UnmarshallingContext navigator, 128 String namespaceURI, 129 String localName) 130 { 131 xmbean.setPersistenceManager(pm); 132 } 133 134 public void setValue(XMBeanConstructorMetaData constructor, 135 UnmarshallingContext navigator, 136 String namespaceUri, 137 String localName, 138 String value) 139 { 140 if("description".equals(localName)) 141 { 142 constructor.setDescription(value); 143 } 144 else if("name".equals(localName)) 145 { 146 constructor.setName(value); 147 } 148 } 149 150 public void setValue(XMBeanAttributeMetaData attribute, 151 UnmarshallingContext navigator, 152 String namespaceUri, 153 String localName, 154 String value) 155 { 156 if("description".equals(localName)) 157 { 158 attribute.setDescription(value); 159 } 160 else if("name".equals(localName)) 161 { 162 attribute.setName(value); 163 } 164 else if("type".equals(localName)) 165 { 166 attribute.setType(value); 167 } 168 } 169 170 public void setValue(XMBeanOperationMetaData operation, 171 UnmarshallingContext navigator, 172 String namespaceUri, 173 String localName, 174 String value) 175 { 176 if("description".equals(localName)) 177 { 178 operation.setDescription(value); 179 } 180 else if("name".equals(localName)) 181 { 182 operation.setName(value); 183 } 184 else if("return-type".equals(localName)) 185 { 186 operation.setReturnType(value); 187 } 188 } 189 190 public void setValue(XMBeanNotificationMetaData notification, 191 UnmarshallingContext navigator, 192 String namespaceUri, 193 String localName, 194 String value) 195 { 196 if("description".equals(localName)) 197 { 198 notification.setDescription(value); 199 } 200 else if("name".equals(localName)) 201 { 202 notification.setName(value); 203 } 204 else if("notification-type".equals(localName)) 205 { 206 notification.setNotificationType(value); 207 } 208 } 209 } 210 | Popular Tags |