/** * Performs contextual operation call on the operation referred by this call object. * * @param self a <code>non-null</code> context type instance on which the invocation is performed * @param arguments actual parameter values passed to the invocation or <code>null</code> in no * parameters are defined * @return the value returned by this call invocation * @exception IllegalArgumentException if the <code>self</code> does not conform to the operation * context type or the <code>arguments</code> do not conform to corresponding parameter types * or the underlying operation is non-contextual * @exception InvocationTargetException if the underling operation throws an exception * @see #invoke(Object[]) */ private Object doInvoke(Object self, Object[] arguments) throws IllegalArgumentException, InvocationTargetException { if (self == null) { throw new IllegalArgumentException("Null context instance"); // $NON-NLS-1$ } Object[] actualArguments = (arguments == null) ? NO_ARGS : arguments; checkArgumentType(self, actualArguments); QvtOperationalEvaluationVisitorImpl evaluator = fContext.getEvaluator(); Object result = null; try { result = evaluator.executeHelperOperation(fOperation, self, Arrays.asList(actualArguments)); if (result == evaluator .getOperationalEvaluationEnv() .getAdapter(InternalEvaluationEnv.class) .getInvalid()) { // OclInvalid is not valid for non-QVT external callers result = null; } } catch (RuntimeException e) { throw new InvocationTargetException(e); } return result; }
/** * Invokes as a library module owned (non-contextual) operation. * * @param arguments actual parameter values passed to the invocation or <code>null</code> in no * parameters are defined * @return the value returned by this call invocation * @exception IllegalArgumentException if the <code>arguments</code> do not conform to * corresponding parameter types or the underlying operation is contextual * @exception InvocationTargetException if the underling operation throws an exception * @see #invoke(Object, Object[]) */ public Object invoke(Object[] arguments) throws IllegalArgumentException, InvocationTargetException { if (isContextual()) { throw new IllegalArgumentException("Contextual operation called without self"); // $NON-NLS-1$ } QvtOperationalEvaluationVisitorImpl evaluator = fContext.getEvaluator(); Object thisObject = evaluator.getOperationalEvaluationEnv().getThisOfType(this.fOwningModule); assert thisObject != null; return doInvoke(thisObject, arguments); }