1 28 29 package org.objectweb.openccm.uml.transformation.ast; 30 31 import ispuml.mdaTransformation.TransformationException; 32 import ispuml.mdaTransformation.model.ModelUtil; 33 import ispuml.mdaTransformation.model.PropertyUtil; 34 35 import java.lang.reflect.InvocationTargetException ; 36 import java.util.Comparator ; 37 import java.util.List ; 38 39 import javax.jmi.reflect.RefPackage; 40 import javax.jmi.reflect.RefObject; 41 42 import org.objectweb.openccm.ast.api.Scope; 43 44 48 public class CCMASTModelUtil implements ModelUtil { 49 50 51 protected PropertyUtil propUtil; 52 53 54 private final String [] declareConcept = {"AbstractInterface", 55 "AbstractStorageHome", 56 "AbstractStorageType", 57 "CidlModule", 58 "Component", 59 "Event", 60 "Interface", 61 "LocalInterface", 62 "Module", 63 "PsdlModule", 64 "StorageType", 65 "Struct", 66 "Union", 67 "Value"}; 68 69 70 private final String [] startConcept = {"Alias", 71 "Attribute", 72 "Composition", 73 "Constant", 74 "Consumes", 75 "Emits", 76 "Enum", 77 "Exception", 78 "Executor", 79 "Factory", 80 "FileScope", 81 "Finder", 82 "Home", 83 "HomeExecutor", 84 "Initializer", 85 "Native", 86 "Operation", 87 "Provides", 88 "PsdlOperation", 89 "Publishes", 90 "Segment", 91 "StorageHome", 92 "StorageTypeStateMember", 93 "StorageTypeStoreDirective", 94 "Uses", 95 "ValueBox", 96 "ValueMember"}; 97 98 99 103 public CCMASTModelUtil() { 104 throw new UnsupportedOperationException ("Not yet implemented."); 105 } 106 107 111 protected CCMASTModelUtil(Scope scope) { 112 Scopes.pushScope(scope); 113 } 114 115 119 public CCMASTModelUtil(PropertyUtil propUtil, Scope scope) { 120 this(scope); 121 this.propUtil = propUtil; 122 } 123 124 132 private java.lang.reflect.Method getCreationMethod(Scope scope, String conceptName) throws NoSuchMethodException { 133 String methodName = conceptName; 134 if (java.util.Arrays.binarySearch(declareConcept, conceptName, new StringComparator()) >= 0) 135 methodName = "declare" + conceptName; 136 if (java.util.Arrays.binarySearch(startConcept, conceptName, new StringComparator()) >= 0) 137 methodName = "start" + conceptName; 138 Class [] param = { String .class }; 139 java.lang.reflect.Method method = scope.getClass().getMethod(methodName, param); 140 return method; 141 } 142 143 147 private class StringComparator implements Comparator { 148 154 public int compare(Object o1, Object o2) { 155 return ((String )o1).compareTo((String )o2); 156 } 157 } 158 159 160 161 167 public Object createInstance(String conceptName) throws InstantiationException { 168 try { 169 java.lang.reflect.Method method = getCreationMethod(Scopes.getScope(), conceptName); 170 String [] param = { "noname" }; 171 Object obj = method.invoke(Scopes.getScope(), param); 173 return obj; 175 } catch (NoSuchMethodException nsme) { 176 throw new InstantiationException ("The concept '" + conceptName + "' has no declareXXX or startXXX method."); 177 } catch (IllegalAccessException e) { 178 throw new InstantiationException (e.getMessage()); 179 } catch (IllegalArgumentException e) { 180 throw new InstantiationException (e.getMessage()); 181 } catch (InvocationTargetException e) { 182 throw new InstantiationException (e.getMessage()); 183 } 184 } 185 186 192 protected RefObject getStereotype(Object object, String stereotype) { 193 throw new UnsupportedOperationException ("Not implemented."); 194 } 195 196 202 public boolean isStereotyped(Object object, String stereotype) { 203 throw new UnsupportedOperationException ("Not implemented."); 204 } 205 206 211 public List getStereotypes(Object object) { 212 throw new UnsupportedOperationException ("Not implemented."); 213 } 214 215 220 public void addStereotype(Object object, String stereotype) { 221 throw new UnsupportedOperationException ("Not yet implemented."); 222 } 223 224 232 public Object getStereotypeTaggedValue(Object object, String stereotype, String attributeName) throws TransformationException { 233 throw new UnsupportedOperationException ("Not implemented."); 234 } 235 236 245 public void setStereotypeTaggedValue(Object object, String stereotype, String attributeName, Object value) 246 throws TransformationException { 247 throw new UnsupportedOperationException ("Not yet implemented."); 248 } 249 250 259 public boolean isOwnerOf(Object object) { 260 return true; 261 } 262 263 269 public boolean isInstanceOf(Object object, String instanceName) { 270 throw new UnsupportedOperationException ("Not implemented."); 271 } 272 273 278 public boolean isModelOutermostPackage(Object object) { 279 throw new UnsupportedOperationException ("Not implemented."); 280 } 281 282 288 protected Object getRefClassByConceptName(String conceptName) { 289 throw new UnsupportedOperationException ("Not implemented."); 290 } 291 292 300 protected RefPackage getRefPackageByConceptName(String conceptName) { 301 throw new UnsupportedOperationException ("Not implemented."); 302 } 303 304 312 protected Object getRefAssociationByConceptName(String conceptName) { 313 throw new UnsupportedOperationException ("Not implemented."); 314 } 315 316 320 public void setPropertyUtil(PropertyUtil propUtil) { 321 this.propUtil = propUtil; 322 } 323 324 328 public PropertyUtil getPropertyUtil() { 329 return propUtil; 330 } 331 332 } 333 | Popular Tags |