@Override public EOperation define(EcoreEnvironment env) { EOperation eOperation = EcoreFactory.eINSTANCE.createEOperation(); eOperation.setName(fName); int pos = 0; for (EClassifier cls : fParamTypes) { EParameter eParam = EcoreFactory.eINSTANCE.createEParameter(); String paramName = cls.getName(); if (fParamNames != null) { paramName = fParamNames[pos++]; } eParam.setName(paramName); eParam.setEType(cls); eOperation.getEParameters().add(eParam); } eOperation.setEType(fReturnType); assert fContextType instanceof EClass; ((EClass) fContextType).getEOperations().add(eOperation); CallHandlerAdapter.attach(eOperation, fDispatcher); return eOperation; }
public Object invoke( ModuleInstance module, Object source, Object[] args, QvtOperationalEvaluationEnv evalEnv) { String self = (String) source; Object arg0 = args[0]; if (arg0 == null && arg0 == CallHandlerAdapter.getInvalidResult(evalEnv)) { return self; } Object arg1 = args[1]; if (arg1 == null && arg1 == CallHandlerAdapter.getInvalidResult(evalEnv)) { return CallHandlerAdapter.getInvalidResult(evalEnv); } return self.replace((String) arg0, (String) arg1); }
public Object invoke( ModuleInstance module, Object source, Object[] args, QvtOperationalEvaluationEnv evalEnv) { Object leftVal = args[0]; if (leftVal == null && leftVal == CallHandlerAdapter.getInvalidResult(evalEnv)) { return CallHandlerAdapter.getInvalidResult(evalEnv); } String self = (String) source; String arg = (String) leftVal; int pos = self.indexOf(arg); if (pos < 0) { return null; } return self.substring(pos + arg.length()); }
public void define(EcoreEnvironment env) { for (OperationProvider operation : getOperations()) { EOperation defOper = operation.define(env); if (operation.fIsStatic) { QvtOperationalParserUtil.markAsStaticOperation(defOper); } if (CallHandlerAdapter.getDispatcher(defOper) == UNSUPPORTED_OPER) { QvtOperationalParserUtil.markAsUnsupported(defOper); } } }
public Object invoke( ModuleInstance module, Object source, Object[] args, QvtOperationalEvaluationEnv evalEnv) { Object leftVal = args[0]; if (leftVal == null && leftVal == CallHandlerAdapter.getInvalidResult(evalEnv)) { return false; } String counterName = (String) leftVal; return StringCounter.getInstance(evalEnv).increment(counterName); }
public Object invoke( ModuleInstance module, Object source, Object[] args, QvtOperationalEvaluationEnv evalEnv) { Object leftVal = args[0]; if (leftVal == null && leftVal == CallHandlerAdapter.getInvalidResult(evalEnv)) { return source; } String quoteStr = (String) leftVal; String self = (String) source; return quoteStr + self + quoteStr; }
public Object invoke( ModuleInstance module, Object source, Object[] args, QvtOperationalEvaluationEnv evalEnv) { String self = (String) source; Object leftVal = args[0]; if (leftVal == null && leftVal == CallHandlerAdapter.getInvalidResult(evalEnv)) { return -1; } return self.lastIndexOf((String) leftVal) + 1; }
public Object invoke( ModuleInstance module, Object source, Object[] args, QvtOperationalEvaluationEnv evalEnv) { String self = (String) source; Object leftVal = args[0]; if (leftVal == null && leftVal == CallHandlerAdapter.getInvalidResult(evalEnv)) { return false; } return Boolean.valueOf(Pattern.matches((String) leftVal, self)); }
public Object invoke( ModuleInstance module, Object source, Object[] args, QvtOperationalEvaluationEnv evalEnv) { Object leftVal = args[0]; if (leftVal == null && leftVal == CallHandlerAdapter.getInvalidResult(evalEnv)) { return false; } Integer arg = (Integer) leftVal; Object self = AS_INTEGER.invoke(module, source, args, evalEnv); return Boolean.valueOf(arg.equals(self)); }
public Object invoke( ModuleInstance module, Object source, Object[] args, QvtOperationalEvaluationEnv evalEnv) { if (!Boolean.TRUE.equals(IS_QUOTED.invoke(module, source, args, evalEnv))) { return source; } Object leftVal = args[0]; if (leftVal == null && leftVal == CallHandlerAdapter.getInvalidResult(evalEnv)) { return false; } String quoteStr = (String) leftVal; String self = (String) source; return self.substring(quoteStr.length(), self.length() - quoteStr.length()); }
public Object invoke( ModuleInstance module, Object source, Object[] args, QvtOperationalEvaluationEnv evalEnv) { Object leftVal = args[0]; if (leftVal == null && leftVal == CallHandlerAdapter.getInvalidResult(evalEnv)) { return false; } String quoteStr = (String) leftVal; String self = (String) source; return Boolean.valueOf( self.length() >= (quoteStr.length() * 2) && self.startsWith(quoteStr) && self.endsWith(quoteStr)); }
public Object invoke( ModuleInstance module, Object source, Object[] args, QvtOperationalEvaluationEnv evalEnv) { Object leftVal = args[0]; if (leftVal == null && leftVal == CallHandlerAdapter.getInvalidResult(evalEnv)) { return false; } Number arg = (Number) leftVal; Object self = AS_FLOAT.invoke(module, source, args, evalEnv); if (self != null) { return arg.doubleValue() == ((Number) self).doubleValue(); } return Boolean.valueOf(false); }
public Object invoke( ModuleInstance module, Object source, Object[] args, QvtOperationalEvaluationEnv evalEnv) { Object leftVal = args[0]; if (leftVal == null && leftVal == CallHandlerAdapter.getInvalidResult(evalEnv)) { return false; } String self = (String) source; for (int i = 0; i < self.length(); i++) { char c = self.charAt(i); if ((i == 0 && !UCharacter.isLetter(c)) || !UCharacter.isLetterOrDigit(c)) { return Boolean.FALSE; } } return Boolean.TRUE; }
public EOperation define(EcoreEnvironment env) { List<Variable<EClassifier, EParameter>> argList = new ArrayList<Variable<EClassifier, EParameter>>(); int pos = 0; for (EClassifier cls : fParamTypes) { Variable<EClassifier, EParameter> stringVariable = ExpressionsFactory.eINSTANCE.createVariable(); String paramName = cls.getName(); if (fParamNames != null) { paramName = fParamNames[pos++]; } stringVariable.setName(paramName); stringVariable.setType(cls); argList.add(stringVariable); } EOperation result = env.defineOperation( fContextType, fName, fReturnType, argList, org.eclipse.ocl.ecore.EcoreFactory.eINSTANCE.createConstraint()); CallHandlerAdapter.attach(result, fDispatcher); if (fIsDeprecated) { if (fDeprecatedBy != null) { QvtOperationalParserUtil.markAsDeprecated(result, fDeprecatedBy); } else { QvtOperationalParserUtil.markAsDeprecated(result); } } return result; }