当前位置: 首页>>代码示例>>Java>>正文


Java Variable.setName方法代码示例

本文整理汇总了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);
	  }
}
 
开发者ID:SOM-Research,项目名称:EMFtoCSP,代码行数:38,代码来源:EmfToEclCodeGenerator.java

示例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;
}
 
开发者ID:road-framework,项目名称:ROADDesigner,代码行数:11,代码来源:SmcOCLFactory.java


注:本文中的org.eclipse.ocl.expressions.Variable.setName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。