1 28 29 package org.objectweb.openccm.uml.transformation.rules.xml; 30 31 import javax.jmi.reflect.RefPackage; 32 33 import ispuml.mdaTransformation.RuleContext; 34 import ispuml.mdaTransformation.TransformationException; 35 import ispuml.mdaTransformation.model.SimpleModelContext; 36 import ispuml.mdaTransformation.model.jmi.JmiModelUtil; 37 import ispuml.mdaTransformation.rules.xml.DataTypeCondition; 38 39 44 public class EnumDataTypeCondition extends DataTypeCondition { 45 46 47 private String model; 48 49 50 private String type; 51 52 53 57 public void setModel(String model) { 58 this.model = model; 59 } 60 61 65 public void setType(String type) { 66 this.type = type; 67 } 68 69 74 protected Object executeCreate(Object object, RuleContext context) throws TransformationException { 75 SimpleModelContext modelContext = (SimpleModelContext)context.getEngineContext().getModel(model); 76 JmiModelUtil modelUtil = (JmiModelUtil)modelContext.getModelUtil(); 77 RefPackage extent = modelUtil.getOutermostRefPackage(); 78 79 String [] names = type.split( "\\." ); 80 int i=0; 81 for(i=0; i<names.length-1; i++ ) { 82 extent = (RefPackage)extent.refPackage( names[i] ); 83 } 84 85 EnumerationRule rule = (EnumerationRule)context.getCurrentRuleContext().getRule(); 86 return extent.refGetEnum(type, rule.getEquivalentLabel(object)); 87 } 88 89 } 90 | Popular Tags |