Пример #1
0
 private boolean isValidNamespace(MGeneralization gen, MNamespace ns) {
   if (gen.getParent() == null || gen.getChild() == null) return true;
   MNamespace ns1 = gen.getParent().getNamespace();
   MNamespace ns2 = gen.getChild().getNamespace();
   if (ns == getFirstSharedNamespace(ns1, ns2)) return true;
   return false;
 }
Пример #2
0
 /**
  * Returns the destination of a relation. The destination of a relation is defined as the
  * modelelement that receives this relation. If there are more then 1 destinations, only the first
  * is returned. If there is no destination, null is returned. Examples of sources include
  * classifiers that are types to associationends, usecases that are bases to extend and include
  * relations and so on. In the case of an association, the destination is defined as the type of
  * the second element in the connections list.
  *
  * @param relation
  * @return MModelElement
  */
 public MModelElement getDestination(MRelationship relation) {
   if (relation instanceof MAssociation) {
     MAssociation assoc = (MAssociation) relation;
     List conns = assoc.getConnections();
     if (conns.size() <= 1) return null;
     return ((MAssociationEnd) conns.get(1)).getType();
   }
   if (relation instanceof MGeneralization) {
     MGeneralization gen = (MGeneralization) relation;
     return gen.getChild();
   }
   if (relation instanceof MDependency) {
     MDependency dep = (MDependency) relation;
     Collection col = dep.getClients();
     if (col.isEmpty()) return null;
     return (MModelElement) (col.toArray())[0];
   }
   if (relation instanceof MFlow) {
     MFlow flow = (MFlow) relation;
     Collection col = flow.getTargets();
     if (col.isEmpty()) return null;
     return (MModelElement) (col.toArray())[0];
   }
   if (relation instanceof MExtend) {
     MExtend extend = (MExtend) relation;
     return extend.getBase();
   }
   if (relation instanceof MInclude) {
     MInclude include = (MInclude) relation;
     return include.getAddition();
   }
   return null;
 }
Пример #3
0
  /**
   * This method returns all Classifiers of which this class is a direct supertype.
   *
   * @param cls the class you want to have the children for
   * @return a collection of the children, each of which is a {@link MGeneralizableElement
   *     MGeneralizableElement}
   */
  public Collection getSubtypes(MClassifier cls) {

    Collection result = new Vector();
    Collection gens = cls.getSpecializations();
    Iterator genIterator = gens.iterator();

    while (genIterator.hasNext()) {
      MGeneralization next = (MGeneralization) genIterator.next();
      result.add(next.getChild());
    }
    return result;
  }
Пример #4
0
 /**
  * Returns all classifiers that extend some classifier clazz.
  *
  * @param clazz
  * @return Collection
  */
 public Collection getExtendingClassifiers(MClassifier clazz) {
   if (clazz == null) return new ArrayList();
   Iterator it = clazz.getSpecializations().iterator();
   List list = new ArrayList();
   while (it.hasNext()) {
     MGeneralization gen = (MGeneralization) it.next();
     MGeneralizableElement client = gen.getChild();
     if (client instanceof MClassifier) {
       list.add(client);
     }
   }
   return list;
 }
 public java.util.Enumeration gen(Object o) {
   MClass c = (MClass) o;
   Vector specs = new Vector(c.getSpecializations());
   if (specs == null) {
     return EnumerationEmpty.theInstance();
   }
   // TODO: it would be nice to have a EnumerationXform
   // and a Functor object in uci.util
   Vector specClasses = new Vector(specs.size());
   java.util.Enumeration enum = specs.elements();
   while (enum.hasMoreElements()) {
     MGeneralization g = (MGeneralization) enum.nextElement();
     MGeneralizableElement ge = g.getChild();
     // assert: ge != null
     if (ge != null) specClasses.addElement(ge);
   }
   return specClasses.elements();
 }