1 28 29 package org.objectweb.openccm.uml.transformation.modfact; 30 31 import ispuml.mdaTransformation.TransformationException; 32 import ispuml.mdaTransformation.NotFoundException; 33 import ispuml.mdaTransformation.model.PropertyUtil; 34 import ispuml.mdaTransformation.model.jmi.JmiModelUtil; 35 36 import java.util.List ; 37 import java.util.ArrayList ; 38 import java.util.Collection ; 39 import java.util.Iterator ; 40 import java.util.Vector ; 41 42 import javax.jmi.reflect.RefPackage; 43 import javax.jmi.reflect.RefObject; 44 import javax.jmi.reflect.JmiException; 45 46 49 public class JmiModFactUML14ModelUtil extends JmiModelUtil { 50 51 55 public JmiModFactUML14ModelUtil() { 56 throw new UnsupportedOperationException ("Not yet implemented."); 57 } 58 59 63 protected JmiModFactUML14ModelUtil(RefPackage outermostRefPackage) { 64 super(outermostRefPackage); 65 } 66 67 71 public JmiModFactUML14ModelUtil(PropertyUtil propUtil, RefPackage outermostRefPackage) { 72 super(propUtil, outermostRefPackage); 73 } 74 75 81 public Object createInstance(String conceptName) throws InstantiationException { 82 RefPackage extent = getOutermostRefPackage(); 83 String [] names = conceptName.split("\\."); 84 try { 85 return getRefClassByConceptName(conceptName).refCreateInstance(null); 87 } catch (JmiException ex) { 88 ex.printStackTrace(); 89 throw new InstantiationException (ex.getMessage()); 90 } 91 } 92 93 99 protected RefObject getStereotype(Object object, String stereotype) { 100 RefObject modelElement = (RefObject) object; 101 Collection stereotypes = (Collection ) modelElement.refGetValue("stereotype"); 102 Iterator iter = stereotypes.iterator(); 103 while (iter.hasNext()) { 104 RefObject stereotypeElement = (RefObject) iter.next(); 105 if (stereotypeElement.refGetValue("name").equals(stereotype)) { 106 return stereotypeElement; 107 } 108 } 110 return null; 111 } 112 113 119 public boolean isStereotyped(Object object, String stereotype) { 120 RefObject modelElement = (RefObject) object; 121 122 Collection stereotypes = (Collection ) modelElement.refGetValue("stereotype"); 123 Iterator iter = stereotypes.iterator(); 124 while (iter.hasNext()) { 125 RefObject stereotypeElement = (RefObject) iter.next(); 126 if (stereotype.equals(stereotypeElement.refGetValue("name"))) 127 return true; 128 } if (stereotypes.size() == 0 && stereotype.trim().length() == 0) 130 return true; 131 return false; 132 } 133 134 139 public List getStereotypes(Object object) { 140 RefObject modelElement = (RefObject) object; 141 142 Collection stereotypes = (Collection ) modelElement.refGetValue("stereotype"); 143 List res = new ArrayList (stereotypes); 144 return res; 145 } 146 147 152 public void addStereotype(Object object, String stereotype) { 153 throw new UnsupportedOperationException ("Not yet implemented."); 154 } 155 156 164 public Object getStereotypeTaggedValue(Object object, String stereotype, String attributeName) throws TransformationException { 165 RefObject modelElement = (RefObject) object; 166 Collection tagValues = (Collection ) modelElement.refGetValue("taggedValue"); 167 Iterator iter = tagValues.iterator(); 168 while (iter.hasNext()) { 169 RefObject tag = (RefObject) iter.next(); 170 if (tag != null) { 171 RefObject tagDef = (RefObject) tag.refGetValue("type"); 172 if (tagDef != null) { 173 String tagName = (String ) tagDef.refGetValue("name"); 174 RefObject owner = (RefObject)tagDef.refGetValue("owner"); 175 if (tagName != null && attributeName.equals(tagName) 176 && ((owner != null && owner.refGetValue("name").equals(stereotype)) 177 || (owner == null && stereotype.trim().length() == 0))) 178 return ((Vector ) tag.refGetValue("dataValue")).get(0); 179 } 180 } 181 } throw new NotFoundException("Can't find tagValue '" + attributeName + "', '" + stereotype + "'."); 183 } 184 185 194 public void setStereotypeTaggedValue(Object object, String stereotype, String attributeName, Object value) 195 throws TransformationException { 196 throw new UnsupportedOperationException ("Not yet implemented."); 197 } 198 199 } 200 | Popular Tags |