View Javadoc

1   package org.andromda.core.simpleuml;
2   
3   import java.util.Collection;
4   import java.util.Iterator;
5   import java.util.Vector;
6   
7   import org.andromda.core.uml14.UMLStaticHelper;
8   import org.omg.uml.foundation.core.Classifier;
9   import org.omg.uml.foundation.core.UmlClass;
10  import org.omg.uml.modelmanagement.UmlPackage;
11  
12  /***
13   * dynamic proxy for a Package: dynamically supports the UMLPackage, 
14   * and org.omg.uml.modelmanagement.UmlPackage interfaces.
15   * 
16   * @author <A HREF="http://www.amowers.com">Anthony Mowers</A>
17   */
18  public class PPackage 
19      extends PModelElement 
20      implements UMLPackage 
21  {
22  
23      public static UmlPackage newInstance(
24          UMLStaticHelper scriptHelper,
25          UmlPackage umlPackage)
26      {
27          Class[] interfaces = new Class[]
28              {
29              UMLPackage.class,
30              UmlPackage.class
31              };
32  
33          return (UmlPackage)java.lang.reflect.Proxy.newProxyInstance(
34              umlPackage.getClass().getClassLoader(),
35              interfaces,
36              new PPackage(umlPackage, scriptHelper));
37      }
38  
39  
40      
41      private PPackage(
42          UmlPackage umlPackage,
43          UMLStaticHelper scriptHelper)
44      {
45          super(umlPackage,scriptHelper);
46      }
47  
48  	public Collection getClasses() 
49      {
50          UmlPackage umlPackage = (UmlPackage)modelElement;
51          Collection contents = umlPackage.getOwnedElement();
52          Collection classProxies = new Vector();
53          
54          for (Iterator i = contents.iterator(); i.hasNext(); )
55          {
56              Object o = i.next();
57              if (o instanceof UmlClass)
58              {
59                  o = PClassifier.newInstance(scriptHelper,(Classifier)o);
60                  classProxies.add(o);
61              }
62          }
63             
64  		return classProxies;
65  	}
66  
67  }