예제 #1
0
 private String getOperationType(UMLElement element, String typeId) throws ContractException {
   if ("List".equals(element.getName())) {
     String setId = JDHelper.getNewId();
     this.insertSet(setId, element.getName(), CommonElementsPackage.JAVAVOID);
     return setId;
   } else {
     String operationType = queryType(element.getName());
     if (operationType == null || "null".equals(operationType)) {
       operationType = typeId;
     }
     return operationType;
   }
 }
예제 #2
0
  private void insertMethodOperations(UMLClass classInst, List<UMLOperation> operationArray)
      throws ContractException {
    for (UMLOperation operation : operationArray) {
      // Return
      String typeId = processID(operation.getType());
      UMLElement element = (UMLElement) parser.getDataTypes().get(typeId);
      String operationType = getOperationType(element, typeId);
      this.insertOperation(
          operation.getId(),
          operation.getName(),
          operation.getVisibility(),
          operationType,
          classInst.getId());

      // Parameters
      for (UMLElement parameter : operation.getParameters()) {
        String parameterType = getParameterType(operation, parameter);
        this.insertParameter(
            parameter.getId(), parameter.getName(), parameterType, operation.getId());
      }
    }
  }
예제 #3
0
 private String getParameterType(UMLOperation operation, UMLElement parameter)
     throws ContractException {
   try {
     String parameterType = operation.getParameterType(parameter.getId());
     UMLElement pElement = (UMLElement) parser.getDataTypes().get(processID(parameterType));
     if (pElement != null) {
       // Eh um DataType
       if ("List".equals(pElement.getName())) {
         String setId = JDHelper.getNewId();
         this.insertSet(setId, pElement.getName(), CommonElementsPackage.JAVAVOID);
         parameterType = setId;
       } else {
         parameterType = queryType(pElement.getName());
         if (parameterType != null) {
           return parameterType;
         }
       }
     }
     return processID(operation.getParameterType(parameter.getId()));
   } catch (Exception ex) {
     throw new ContractException("Can't recover parameter type", ex);
   }
 }