View Javadoc

1   /*
2    * UML2MMBase module.
3    *
4    * The contents of this file are subject to the Mozilla Public License
5    * Version 1.0 (the "License"); you may not use this file except in
6    * compliance with the License. You may obtain a copy of the License at
7    * http://www.mozilla.org/MPL/
8    *
9    * Software distributed under the License is distributed on an "AS IS"
10   * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
11   * License for the specific language governing rights and limitations
12   * under the License.
13   */
14  
15  package com.finalist.mmbase.uml;
16  
17  import com.finalist.mmbase.umlprofile.MMBaseUMLProfile;
18  
19  import java.util.Collection;
20  import java.util.ArrayList;
21  import java.util.Iterator;
22  
23  /***
24   *
25   * Helper classes to get access to MMBasePackages.
26   *
27   * @author Rudie Ekkelenkamp - Finalist IT Group
28   * @version $Revision: 1.2 $, $Date: 2004/12/08 23:27:32 $
29   *
30   */
31  public class MMBasePackageHelper extends MMBaseHelper {
32  
33     /***  Default constructor. */
34     public MMBasePackageHelper(Object model) {
35        // Ensure the model is set.
36        setModel(model);
37     }
38  
39     /***
40      * Returns a collection of String's with the package names.
41      * that have the MMBasePackage stereotype name.
42      * These packages are UML2MMBase packages that can be selected for codegeneration.
43      *
44      * @return Collection with package names.
45      */
46     public Collection getMMBasePackages() {
47         ArrayList result = new ArrayList();
48         // Get model elements that are packages with the stereotype:
49         //
50         Collection modelElements = getModelElements();
51         for (Iterator iterator = modelElements.iterator(); iterator.hasNext();) {
52             Object o = iterator.next();
53             if (super.isPackage(o) && MMBaseUMLProfile.STEREOTYPE_PACKAGE_MMBASE_PACKAGE.equals(super.getStereotype(o))) {
54                  result.add("" + super.getName(o));
55             }
56         }
57         return result;
58     }
59  }