1 28 29 package org.objectweb.openccm.uml.transformation.ast; 30 31 import ispuml.mdaTransformation.RuleContext; 32 import ispuml.mdaTransformation.TransformationException; 33 import ispuml.mdaTransformation.ActionBase; 34 import ispuml.mdaTransformation.rules.xml.CompositeXmlAction; 35 36 42 public class OperationParameters extends CompositeXmlAction { 43 44 47 public OperationParameters() { 48 isSrcPropertyRequired = false; 51 isDstPropertyRequired = false; 52 action = new TransformAction(); 53 } 54 55 58 class TransformAction extends ActionBase { 59 64 public Object execute(Object bean, RuleContext request) throws TransformationException { 65 org.omg.uml.core.Operation operation = (org.omg.uml.core.Operation) bean; 66 CCMASTModelContext context; 67 context = (CCMASTModelContext) request.engineContext.getModel("ccm-ast"); 68 org.objectweb.openccm.ast.api.OperationDecl op = (org.objectweb.openccm.ast.api.OperationDecl) request.getAttribute("declaration"); 69 70 java.util.Iterator parameters = operation.getParameter().iterator(); 71 while (parameters.hasNext()) { 72 org.omg.uml.core.Parameter param = (org.omg.uml.core.Parameter) parameters.next(); 73 74 org.objectweb.openccm.ast.api.TypeRef typeParameter = getType(param.getType()); 77 78 if (param.getKind() == org.omg.uml.datatypes.ParameterDirectionKindEnum.PDK_IN) { 79 op.getParameterList().addInParam(param.getName(), typeParameter); 80 } else if (param.getKind() == org.omg.uml.datatypes.ParameterDirectionKindEnum.PDK_OUT) { 81 op.getParameterList().addOutParam(param.getName(), typeParameter); 82 } else if (param.getKind() == org.omg.uml.datatypes.ParameterDirectionKindEnum.PDK_INOUT) { 83 op.getParameterList().addInOutParam(param.getName(), typeParameter); 84 } else if (param.getKind() == org.omg.uml.datatypes.ParameterDirectionKindEnum.PDK_RETURN) { 85 op.setType(typeParameter); 86 } 87 } 88 89 return null; 90 } 91 92 97 private org.objectweb.openccm.ast.api.TypeRef getType(org.omg.uml.core.Classifier type) { 98 String typeName = type.getName().toLowerCase(); 99 if (typeName.equals("short")) 100 return CCMASTModelCreateUtils.getAst().getShortType(); 101 else if (typeName.equals("long")) 102 return CCMASTModelCreateUtils.getAst().getLongType(); 103 else if (typeName.equals("long long")) 104 return CCMASTModelCreateUtils.getAst().getLongLongType(); 105 else if (typeName.equals("double")) 106 return CCMASTModelCreateUtils.getAst().getDoubleType(); 107 else if (typeName.equals("long double")) 108 return CCMASTModelCreateUtils.getAst().getLongDoubleType(); 109 else if (typeName.equals("unsigned short")) 110 return CCMASTModelCreateUtils.getAst().getUShortType(); 111 else if (typeName.equals("unsigned long")) 112 return CCMASTModelCreateUtils.getAst().getULongType(); 113 else if (typeName.equals("unsigned long long")) 114 return CCMASTModelCreateUtils.getAst().getULongLongType(); 115 else if (typeName.equals("any")) 116 return CCMASTModelCreateUtils.getAst().getAnyType(); 117 else if (typeName.equals("boolean")) 118 return CCMASTModelCreateUtils.getAst().getBooleanType(); 119 else if (typeName.equals("string")) 120 return CCMASTModelCreateUtils.getAst().getStringType(); 121 else if (typeName.equals("octet")) 122 return CCMASTModelCreateUtils.getAst().getOctetType(); 123 else if (typeName.equals("void")) 124 return CCMASTModelCreateUtils.getAst().getVoidType(); 125 else if (typeName.equals("char")) 126 return CCMASTModelCreateUtils.getAst().getCharType(); 127 else if (typeName.equals("wchar")) 128 return CCMASTModelCreateUtils.getAst().getWCharType(); 129 else if (typeName.equals("float")) 130 return CCMASTModelCreateUtils.getAst().getFloatType(); 131 else if (typeName.equals("wstring")) 132 return CCMASTModelCreateUtils.getAst().getWStringType(); 133 else if (typeName.equals("typecode")) 134 return CCMASTModelCreateUtils.getAst().getTypeCodeType(); 135 else if (typeName.equals("principal")) 136 return CCMASTModelCreateUtils.getAst().getPrincipalType(); 137 else if (typeName.equals("object")) 138 return CCMASTModelCreateUtils.getAst().getObjectType(); 139 else if (typeName.equals("valuebase")) 140 return CCMASTModelCreateUtils.getAst().getValueBaseType(); 141 else 142 System.out.println("Type " + type.getName() + " unrecognized !"); 143 return null; 144 } 145 146 } } 148 | Popular Tags |