コード例 #1
0
  /**
   * @param classifiers
   * @return
   */
  private String generateConfig(Collection classifiers) {

    String methodList = "";
    String method = "";

    for (Iterator i = classifiers.iterator(); i.hasNext(); ) {
      Classifier klass = (Classifier) i.next();

      // System.out.println("classifier class name: " + klass.getName());

      for (Iterator j = UML13Utils.getAssociationEnds(klass).iterator(); j.hasNext(); ) {
        AssociationEnd thisEnd = (AssociationEnd) j.next();
        AssociationEnd otherEnd = UML13Utils.getOtherAssociationEnd(thisEnd);
        UmlPackage pkg = null;
        if (_pkgName != null) {
          pkg = UML13Utils.getPackage(UML13Utils.getModel(klass), _pkgName);
        } else {
          pkg = UML13Utils.getModel(klass);
        }
        String nn = UML13Utils.getNamespaceName(pkg, klass);

        if (_pkgName != null) {
          pkg = UML13Utils.getPackage(UML13Utils.getModel((UmlClass) otherEnd.getType()), _pkgName);
        } else {
          pkg = UML13Utils.getModel((UmlClass) otherEnd.getType());
        }

        String temp1 = UML13Utils.getNamespaceName(pkg, (UmlClass) otherEnd.getType());
        method = "";
        // the other end is collection, form a string
        if ((UML13Utils.isOne2Many(thisEnd, otherEnd) || UML13Utils.isMany2Many(thisEnd, otherEnd))
            && otherEnd.isNavigable()) {
          method = method + otherEnd.getName();
          method = method + nn;
          method = method + ".";
          //					method = method + ".impl.";
          method = method + thisEnd.getType().getName();
          //					method = method + "Impl";
          method = method + "=";
          method = method + temp1;
          //					method = method + ".impl.";
          method = method + ".";
          method = method + otherEnd.getType().getName();
          //					method = method + "Impl";
          method = method + "\n";

          // 3.0.1 release
          method = method + otherEnd.getName();
          method = method + nn;
          method = method + ".impl.";
          method = method + thisEnd.getType().getName();
          method = method + "Impl";
          method = method + "=";
          method = method + temp1;
          method = method + ".impl.";
          method = method + otherEnd.getType().getName();
          method = method + "Impl";
          method = method + "\n\n";
        }

        if (method != null && methodList != null) {
          methodList = methodList + method;
        } else if (method != null && methodList == null) {
          methodList = method;
        }
      }
    }

    String setUp = "";
    setUp = setUp + methodList;
    return setUp;
  }