EMFt OCL中对OCL标准库操作的扩展操作在package org.eclipse.emf.ocl.expressions.impl里面
具体的方法是public Object visitOperationCallExp(OperationCallExp oc) {}
// if source is undefined and the operation is not
// undefined, then this expression is invalid
if (isUndefined(sourceVal)
&& opCode != PredefinedType.OCL_IS_UNDEFINED
&& opCode != PredefinedType.OCL_IS_INVALID)
return Types.OCL_INVALID;然后处理对应的operation
// evaluate this operation
switch (opCode) ...{
case PredefinedType.MINUS:
// Integer::minus()
if (sourceVal instanceof Integer)
return new Integer(-((Integer) sourceVal)
.intValue());
// Double::minus()
return new Double(-((Double) sourceVal).doubleValue());
其中toUpper()这个方法是对OCL的扩展
case PredefinedType.TO_UPPER:
// String::toUpper()
return UCharacter.toUpperCase((String) sourceVal);
我们可以来分析一下这其中扩展的内容
int opCode = oc.getOperationCode();
对于toUpper这个操作来说,其对应的操作码是29
PredefinedType里面
int TO_UPPER = 29;
String TO_UPPER_NAME = "toUpper"; //$NON-NLS-1$