1 7 package org.jboss.test.xml.multispaced; 8 9 import org.jboss.xb.binding.MarshallingContext; 10 import org.jboss.xb.binding.ObjectModelProvider; 11 12 16 public class XMBeanMetaDataProvider 17 implements ObjectModelProvider 18 { 19 public static final XMBeanMetaDataProvider INSTANCE = new XMBeanMetaDataProvider(); 20 21 private XMBeanMetaDataProvider() {} 22 23 public Object getRoot(Object o, MarshallingContext ctx, String namespaceURI, String localName) 24 { 25 return o; 26 } 27 28 public Object getChildren(XMBeanMetaData xmbean, String namespaceUri, String localName) 29 { 30 Object children; 31 if("mbean".equals(localName)) 32 { 33 children = xmbean; 34 } 35 else if("constructor".equals(localName)) 36 { 37 children = xmbean.getConstructors(); 38 } 39 else if("attribute".equals(localName)) 40 { 41 children = xmbean.getAttributes(); 42 } 43 else if("operation".equals(localName)) 44 { 45 children = xmbean.getOperations(); 46 } 47 else if("notification".equals(localName)) 48 { 49 children = xmbean.getNotifications(); 50 } 51 else if("persistence".equals(localName)) 52 { 53 children = xmbean.getPersistenceManager(); 54 } 55 else 56 { 57 children = null; 58 } 59 return children; 60 } 61 62 public Object getElementValue(XMBeanMetaData xmbean, String namespaceUri, String localName) 63 { 64 Object value; 65 if("description".equals(localName)) 66 { 67 value = xmbean.getDescription(); 68 } 69 else if("class".equals(localName)) 70 { 71 value = xmbean.getMbeanClass(); 72 } 73 else 74 { 75 value = null; 76 } 77 return value; 78 } 79 80 public Object getElementValue(XMBeanConstructorMetaData constructor, String namespaceUri, String localName) 81 { 82 Object value; 83 if("description".equals(localName)) 84 { 85 value = constructor.getDescription(); 86 } 87 else if("name".equals(localName)) 88 { 89 value = constructor.getName(); 90 } 91 else 92 { 93 value = null; 94 } 95 return value; 96 } 97 98 public Object getAttributeValue(XMBeanAttributeMetaData attribute, String namespaceUri, String localName) 99 { 100 Object value; 101 if("access".equals(localName)) 102 { 103 value = attribute.getAccess(); 104 } 105 else if("getMethod".equals(localName)) 106 { 107 value = attribute.getGetMethod(); 108 } 109 else if("setMethod".equals(localName)) 110 { 111 value = attribute.getSetMethod(); 112 } 113 else 114 { 115 value = null; 116 } 117 return value; 118 } 119 120 public Object getElementValue(XMBeanAttributeMetaData attribute, String namespaceUri, String localName) 121 { 122 Object value; 123 if("description".equals(localName)) 124 { 125 value = attribute.getDescription(); 126 } 127 else if("name".equals(localName)) 128 { 129 value = attribute.getName(); 130 } 131 else if("type".equals(localName)) 132 { 133 value = attribute.getType(); 134 } 135 else 136 { 137 value = null; 138 } 139 return value; 140 } 141 142 public Object getElementValue(XMBeanOperationMetaData operation, String namespaceUri, String localName) 143 { 144 Object value; 145 if("description".equals(localName)) 146 { 147 value = operation.getDescription(); 148 } 149 else if("name".equals(localName)) 150 { 151 value = operation.getName(); 152 } 153 else if("return-type".equals(localName)) 154 { 155 value = operation.getReturnType(); 156 } 157 else 158 { 159 value = null; 160 } 161 return value; 162 } 163 164 public Object getElementValue(XMBeanNotificationMetaData notification, String namespaceUri, String localName) 165 { 166 Object value; 167 if("description".equals(localName)) 168 { 169 value = notification.getDescription(); 170 } 171 else if("name".equals(localName)) 172 { 173 value = notification.getName(); 174 } 175 else if("notification-type".equals(localName)) 176 { 177 value = notification.getNotificationType(); 178 } 179 else 180 { 181 value = null; 182 } 183 return value; 184 } 185 } 186 | Popular Tags |