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.Attribute;
9   import org.omg.uml.foundation.core.Classifier;
10  import org.omg.uml.foundation.core.Dependency;
11  import org.omg.uml.foundation.core.Operation;
12  
13  
14  /***
15   * dynamic proxy for a Classifier: dynamically supports the UMLClassifier, 
16   * and org.omg.uml.foundation.core.Classifier interfaces.
17   *
18   *@author    <A HREF="http://www.amowers.com">Anthony Mowers</A>
19   */
20  public class PClassifier
21  	extends PModelElement
22  	implements UMLClassifier
23  {
24  	/***
25  	 *  Description of the Method
26  	 *
27  	 *@param  classifier    Description of the Parameter
28  	 *@param  scriptHelper  Description of the Parameter
29  	 *@return               Description of the Return Value
30  	 */
31  	public static Classifier newInstance(
32  		UMLStaticHelper scriptHelper,
33  		Classifier classifier)
34  	{
35  		Class[] interfaces = {
36  			UMLClassifier.class,
37  			Classifier.class
38  		};
39  		
40  		return (Classifier)java.lang.reflect.Proxy.newProxyInstance(
41  			classifier.getClass().getClassLoader(),
42  			interfaces,
43  			new PClassifier(classifier, scriptHelper));
44  	}
45  
46  
47  	
48  	protected PClassifier(
49  		Classifier classifier,
50  		UMLStaticHelper scriptHelper)
51  	{
52  		super(classifier,scriptHelper);
53  	}
54  
55  
56  
57  	/***
58  	 *  Gets the attributes attribute of the ClassifierProxy object
59  	 *
60  	 *@return    The attributes value
61  	 */
62  	public Collection getAttributes()
63  	{
64  		Collection attributes = scriptHelper.getAttributes(modelElement);
65  		Collection attributeProxies = new Vector();
66  		
67  		for (Iterator i = attributes.iterator(); i.hasNext(); )
68  		{
69  			attributeProxies.add(
70  				PAttribute.newInstance(scriptHelper,(Attribute)i.next()) 
71  				);
72  		}
73  		
74  		return attributeProxies;
75  	}
76  
77  
78  	/***
79  	 *  Gets the dependencies attribute of the ClassifierProxy object
80  	 *
81  	 *@return    The dependencies value
82  	 */
83  	public Collection getDependencies()
84  	{
85  		Collection dependencies = scriptHelper.getDependencies(modelElement);
86  		Collection dependencyProxies = new Vector();
87  		
88  		for (Iterator i = dependencies.iterator(); i.hasNext(); )
89  		{
90  			dependencyProxies.add(
91  				PDependency.newInstance(scriptHelper,(Dependency)i.next())
92  			);
93  		}
94  		
95  		return dependencyProxies;
96  	}
97  
98  
99  	/***
100 	 *  Gets the associationLinks attribute of the ClassifierProxy object
101 	 *
102 	 *@return    The associationLinks value
103 	 */
104 	public Collection getAssociationLinks()
105 	{
106 		return scriptHelper.getAssociationEnds(modelElement);
107 	}
108 
109 
110 	/***
111 	 *  Gets the package attribute of the ClassifierProxy object
112 	 *
113 	 *@return    The package value
114 	 */
115 	public Object getPackage()
116 	{
117 		return this.modelElement;
118 	}
119 
120 	public Collection getOperations()
121 	{
122 		Collection operations = scriptHelper.getOperations(modelElement);
123 		Collection operationProxies = new Vector();
124 
125 
126 		for (Iterator i = operations.iterator(); i.hasNext(); )
127 		{
128 			Object proxy = 
129 				POperation.newInstance(
130 					scriptHelper, 
131 					(Operation) (i.next() )
132 				);
133 				
134 			operationProxies.add(proxy);
135 
136 		}
137 		
138 		
139 		return operationProxies;
140 	}
141 	
142 }
143