/**
  * Instantiate a behavior
  *
  * @param copy copier
  * @param actual actual in template instantiation
  * @param opaqueBehavior behavior with body in form of an Acceleo template.
  * @return instantiated (bound) behavior.
  * @throws TransformationException
  */
 public static OpaqueBehavior instantiateBehavior(
     LazyCopier copy, Element actual, OpaqueBehavior opaqueBehavior)
     throws TransformationException {
   OpaqueBehavior newBehavior = copy.getCopy(opaqueBehavior);
   if (actual instanceof NamedElement) {
     String newName = AcceleoDriverWrapper.evaluate(opaqueBehavior.getName(), actual, null);
     newBehavior.setName(newName);
   }
   EList<String> bodyList = newBehavior.getBodies();
   for (int i = 0; i < bodyList.size(); i++) {
     String body = bodyList.get(i);
     TransformationContext.classifier = (Classifier) newBehavior.getOwner();
     // pass qualified operation name as template name. Used to identify script in case of an error
     String newBody =
         AcceleoDriverWrapper.evaluate(body, newBehavior.getQualifiedName(), actual, null);
     bodyList.set(i, newBody);
   }
   return newBehavior;
 }
Beispiel #2
0
 public Object buildMethod(String name) {
   // in UML2, we model a method as a Behavior (initially OpaqueBehavior)
   OpaqueBehavior method = UMLFactory.eINSTANCE.createOpaqueBehavior();
   method.setName(name);
   return method;
 }