本文整理汇总了Java中org.eclipse.ocl.expressions.Variable.setName方法的典型用法代码示例。如果您正苦于以下问题:Java Variable.setName方法的具体用法?Java Variable.setName怎么用?Java Variable.setName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.ocl.expressions.Variable
的用法示例。
在下文中一共展示了Variable.setName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: insertQuantificationForSelf
import org.eclipse.ocl.expressions.Variable; //导入方法依赖的package包/类
/**
* Add quantification for self variable if required.
* @param helper
* @param contextCls The context of this expression (i.e., the type of "self")
* @param oclExpression The OCL expression to be extended
* @throws ParserException
*/
@SuppressWarnings("rawtypes")
private void insertQuantificationForSelf(OCLHelper<EClassifier, EOperation, EStructuralFeature, Constraint> helper,
EClass contextCls, ExpressionInOCL oclExpression) throws ParserException {
/* TODO: This method inserts the quantification for "self" only if this variable
* occurs. This is working and practical.
* However, the precise semantics of OCL would require that self is always quantified.
* In the long term, a switch for EMFtoCSP should be added.
*/
OCLExpression bodyExp = oclExpression.getBodyExpression();
LookupSelfVariableVisitor lookupVisitor = new LookupSelfVariableVisitor();
bodyExp.accept(lookupVisitor);
Variable<EClassifier, EParameter> selfDecl = lookupVisitor.getResult();
if (selfDecl != null) {
System.err.println("Adding required self variable quantification");
EcorePackage oclPackage = (EcorePackage) oclExpression.eClass().getEPackage();
EcoreFactory oclFactory = (EcoreFactory) oclPackage.getEFactoryInstance();
IteratorExp forAllExp = oclFactory.createIteratorExp();
forAllExp.setName("forAll");
forAllExp.setType((EClassifier) bodyExp.getType());
selfDecl.setName("self");
selfDecl.setType(contextCls);
forAllExp.getIterator().add(selfDecl);
forAllExp.setBody(bodyExp);
helper.setContext(contextCls);
OCLExpression<EClassifier> allInstancesExp = helper.createQuery(contextCls.getName() + ".allInstances()");
forAllExp.setSource(allInstancesExp);
oclExpression.setBodyExpression(forAllExp);
}
}
示例2: createVar
import org.eclipse.ocl.expressions.Variable; //导入方法依赖的package包/类
/**
* @generated
*/
private static Variable createVar(Environment ecoreEnv, String name,
EClassifier type) {
Variable var = EcoreFactory.eINSTANCE.createVariable();
var.setName(name);
var.setType(ecoreEnv.getUMLReflection().getOCLType(type));
return var;
}