Example #1
0
  private void applyFilters() {
    // build filter set
    HashSet<String> filterSet = new HashSet<String>();
    // filter primtives
    if (this.parser.filterPrimitiveClasses) {
      for (UMLClass cl : classList) {
        if (cl.getPackageName().startsWith("java")) {
          filterSet.add(cl.getId());
        }
      }
    }
    // filter root class
    for (UMLClass cl : classList) {
      if (cl.getPackageName().equals("")) {
        filterSet.add(cl.getId());
      }
    }

    // filter classes
    List<UMLClass> filteredClasses = new ArrayList<UMLClass>(this.classList.size());
    for (UMLClass cl : this.classList) {
      if (!filterSet.contains(cl.getId())) {
        filteredClasses.add(cl);
      }
    }
    this.classList = filteredClasses;

    // filter assocations
    List<UMLAssociation> filteredAssociations =
        new ArrayList<UMLAssociation>(this.assocList.size());
    for (UMLAssociation assoc : this.assocList) {
      if (!filterSet.contains(
              assoc
                  .getSourceUMLAssociationEdge()
                  .getUMLAssociationEdge()
                  .getUMLClassReference()
                  .getRefid())
          && !filterSet.contains(
              assoc
                  .getTargetUMLAssociationEdge()
                  .getUMLAssociationEdge()
                  .getUMLClassReference()
                  .getRefid())) {
        filteredAssociations.add(assoc);
      }
    }
    this.assocList = filteredAssociations;

    // filter generalizations
    List<UMLGeneralization> filteredGeneralizations =
        new ArrayList<UMLGeneralization>(this.genList.size());
    for (UMLGeneralization gen : this.genList) {
      if (!filterSet.contains(gen.getSubClassReference().getRefid())
          && !filterSet.contains(gen.getSuperClassReference().getRefid())) {
        filteredGeneralizations.add(gen);
      }
    }
    this.genList = filteredGeneralizations;
  }
Example #2
0
 private void handleClassReference(Attributes atts) {
   if (isWithinAssociationEnd()) {
     edge.getUMLClassReference().setRefid(atts.getValue(XMIConstants.XMI_IDREF));
   } else if (isWithinGeneralizationChild()) {
     UMLGeneralization gen = genList.get(genList.size() - 1);
     gen.getSubClassReference().setRefid(atts.getValue(XMIConstants.XMI_IDREF));
   } else if (isWithinGeneralizationParent()) {
     UMLGeneralization gen = genList.get(genList.size() - 1);
     gen.getSuperClassReference().setRefid(atts.getValue(XMIConstants.XMI_IDREF));
   }
 }
Example #3
0
 private void handleGeneralization(Attributes atts) {
   UMLGeneralization gen = new UMLGeneralization();
   String subId = atts.getValue(XMIConstants.XMI_UML_GENERALIZATION_CHILD);
   String superId = atts.getValue(XMIConstants.XMI_UML_GENERALIZATION_PARENT);
   if (subId == null) {
     subId = atts.getValue(XMIConstants.XMI_UML_GENERALIZATION_SUBTYPE);
   }
   if (superId == null) {
     superId = atts.getValue(XMIConstants.XMI_UML_GENERALIZATION_SUPERTYPE);
   }
   gen.setSubClassReference(new UMLClassReference(subId));
   gen.setSuperClassReference(new UMLClassReference(superId));
   genList.add(gen);
 }
Example #4
0
  private void flattenAttributes() {
    // build parent table
    Map<String, String> parentTable = new HashMap<String, String>();
    for (UMLGeneralization gen : genList) {
      parentTable.put(
          gen.getSubClassReference().getRefid(), gen.getSuperClassReference().getRefid());
    }

    // flatten each cl
    for (String clId : classTable.keySet()) {
      UMLClass cl = classTable.get(clId);
      List<UMLAttribute> flatAttributes = flattenAttributes(parentTable, clId);
      cl.getUmlAttributeCollection().setUMLAttribute(flatAttributes.toArray(new UMLAttribute[0]));
    }
  }