Beispiel #1
0
  @Override
  public void endElement(String uri, String localName, String qName) throws SAXException {
    if (qName.equals(XMIConstants.XMI_UML_PACKAGE)) {
      int index = pkg.lastIndexOf('.');
      if (index == -1) {
        pkg = "";
      } else {
        pkg = pkg.substring(0, index);
      }
    } else if (qName.equals(XMIConstants.XMI_UML_CLASS) && isWithinPackage()) {
      UMLClass cl = classList.get(classList.size() - 1);
      cl.setUmlAttributeCollection(
          new UMLClassUmlAttributeCollection(attribList.toArray(new UMLAttribute[0])));
      attribList.clear();
    } else if (qName.equals(XMIConstants.XMI_UML_ASSOCIATION)) {
      UMLAssociation assoc = assocList.get(assocList.size() - 1);
      if (sourceNavigable && !targetNavigable) {
        UMLAssociationEdge assocEdge = assoc.getSourceUMLAssociationEdge().getUMLAssociationEdge();
        assoc
            .getSourceUMLAssociationEdge()
            .setUMLAssociationEdge(assoc.getTargetUMLAssociationEdge().getUMLAssociationEdge());
        assoc.getTargetUMLAssociationEdge().setUMLAssociationEdge(assocEdge);
      }
      assoc.setBidirectional(sourceNavigable && targetNavigable);
    }

    chars.delete(0, chars.length());
    elementStack.pop();
  }
Beispiel #2
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;
  }