本文整理汇总了Java中org.eclipse.ocl.OCL类的典型用法代码示例。如果您正苦于以下问题:Java OCL类的具体用法?Java OCL怎么用?Java OCL使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OCL类属于org.eclipse.ocl包,在下文中一共展示了OCL类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createViewFilterLinks
import org.eclipse.ocl.OCL; //导入依赖的package包/类
public void createViewFilterLinks() {
for (Filter viewpointFilter : viewpointFilters) {
// Part 1: Execute the ocl query.
if (!viewpointFilter.isFilterOnlyEstructuralFeatures()) {
String oclQuery = viewpointFilter.getOclQuery();
OCL<EPackage, EClassifier, EOperation, EStructuralFeature, EEnumLiteral, EParameter,
EObject, CallOperationAction, SendSignalAction, org.eclipse.ocl.ecore.Constraint,
EClass, EObject> ocl;
ocl = OCL.newInstance(EcoreEnvironmentFactory.INSTANCE);
// create an OCL helper object
helper = ocl.createOCLHelper();
try {
// En el caso que el query sea un allInstances toca crear un extentMap
// para su evaluacion. (Lo que pasa es que en el caso que estoy usando
// no hay condiciones que se apliquen sobre el allInstances)
// TODO El extentMap se necesita solo si el ocl es un allInstances.
ocl.setExtentMap(createExtentMapHelper(viewpointFilter));
OCLExpression<EClassifier> parsedQuery = helper.createQuery(oclQuery);
Query<EClassifier, EClass, EObject> theQueryCreatedByOcl = ocl.createQuery(parsedQuery);
Object objectsToFilter = theQueryCreatedByOcl.evaluate();
if (objectsToFilter instanceof Collection) {
Collection<EObject> objs = (Collection<EObject>) objectsToFilter;
createFilterLinks(objs, viewpointFilter);
} else if (objectsToFilter instanceof EObject) {
createFilterLink((EObject) objectsToFilter, viewpointFilter);
}
// Part 2: Generate the link.
} catch (ParserException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}