コード例 #1
0
  private void checkArgumentType(Object self, Object[] arguments) {
    if (arguments.length != fArgumentTypes.size()) {
      throw new IllegalArgumentException("Parameter count mismatch"); // $NON-NLS-1$
    }

    EvaluationEnvironment<EClassifier, EOperation, EStructuralFeature, EClass, EObject> evalEnv =
        fContext.getEvaluator().getEvaluationEnvironment();
    if (self != null) {
      EClassifier callContextType = fContextType;
      if (callContextType == null) {
        callContextType = fOwningModule;
      }
      if (!evalEnv.isKindOf(self, callContextType)) {
        throw new IllegalArgumentException("Invalid context instance type"); // $NON-NLS-1$
      }
    }

    int argIndex = 0;
    for (EClassifier nextArgType : fArgumentTypes) {
      Object nextArg = arguments[argIndex++];
      if (nextArg != null) {
        if (!evalEnv.isKindOf(nextArg, nextArgType)) {
          throw new IllegalArgumentException(
              "Invalid type of argument, pos = " + argIndex); // $NON-NLS-1$				
        }
      }
    }
  }
コード例 #2
0
ファイル: RowSourceHandler.java プロジェクト: veithen/wasci
 public void execute(TableSink sink) throws ReportExecutionException, TableSinkException {
   EvaluationEnvironment<EClassifier, ?, ?, EClass, EObject> evalEnvironment =
       query.getEvaluationEnvironment();
   evalEnvironment.clear();
   parent.populate(evalEnvironment);
   Object result = query.evaluate();
   if (result instanceof Collection<?>) {
     for (Iterator<?> it = ((Collection<?>) result).iterator(); it.hasNext(); ) {
       current = (EObject) it.next();
       executeChildren(sink);
     }
   } else {
     throw new ReportExecutionException("Failed to execute " + query.getExpression());
   }
 }
コード例 #3
0
ファイル: CollectionUtil.java プロジェクト: ewillink/ocl
  /**
   * Implementation of the OCL <tt>Collection::product(c : Collection(T2)) : Set(Tuple(first : T,
   * second : T2))</tt> operations.
   *
   * @param evalEnv the current evaluation environment (for construction of tuples)
   * @param env the current OCL environment (for introspection of the tuple type)
   * @param self the source collection
   * @param c another collection
   * @return the product of the collections
   */
  public static <PK, C, O, P, EL, PM, S, COA, SSA, CT, CLS, E> Set<Tuple<O, P>> product(
      EvaluationEnvironment<C, O, P, CLS, E> evalEnv,
      Environment<PK, C, O, P, EL, PM, S, COA, SSA, CT, CLS, E> env,
      Collection<?> self,
      Collection<?> c,
      C tupleType) {

    Set<Tuple<O, P>> result = createNewSet();

    Map<P, Object> propertyValues = new HashMap<P, Object>();
    P firstProperty = env.lookupProperty(tupleType, OCLStandardLibraryUtil.PRODUCT_FIRST);
    P secondProperty = env.lookupProperty(tupleType, OCLStandardLibraryUtil.PRODUCT_SECOND);

    for (Object next1 : self) {
      for (Object next2 : c) {
        propertyValues.put(firstProperty, next1);
        propertyValues.put(secondProperty, next2);

        result.add(evalEnv.createTuple(tupleType, propertyValues));
      }
    }

    return result;
  }
コード例 #4
0
ファイル: RowSourceHandler.java プロジェクト: veithen/wasci
 @Override
 public void populate(EvaluationEnvironment<EClassifier, ?, ?, EClass, EObject> evalEnvironment) {
   parent.populate(evalEnvironment);
   evalEnvironment.add(varName, current);
 }