KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > uml > transformation > rules > xml > CopyAssociatedClass


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2004 INRIA - USTL - LIFL - GOAL
5 Contact: openccm@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Pierre Carpentier.
23 Contributor(s): Philippe Merle.
24
25 ---------------------------------------------------------------------
26 $Id: CopyAssociatedClass.java,v 1.1 2004/05/26 11:25:35 carpentier Exp $
27 ====================================================================*/

28
29 package org.objectweb.openccm.uml.transformation.rules.xml;
30
31 import ispuml.mdaTransformation.RuleContext;
32 import ispuml.mdaTransformation.TransformationException;
33 import ispuml.mdaTransformation.rules.xml.BeanProperty;
34 import ispuml.mdaTransformation.rules.xml.CopyXmlAction;
35
36 /**
37  * Action to copy the associated class to a bean or a property.
38  *
39  * @author Pierre Carpentier
40  */

41 public class CopyAssociatedClass extends CopyXmlAction {
42     
43     /** The search stereotype of the association. */
44     private String JavaDoc associatedClassWithStereotype;
45     
46     /** The stereotype of the class associated by the search association. */
47     private String JavaDoc associatedClassHasStereotype;
48     
49     /** The type of the search association. */
50     private String JavaDoc associatedClassWithType;
51
52     /** The Util class which offers methods to retrieve the associated class. */
53     private AssociatedClassUtils assoClassUtils;
54     
55     
56     /**
57      * Default Constructor
58      */

59     public CopyAssociatedClass () {
60         super();
61         assoClassUtils = new AssociatedClassUtils();
62         srcProperty = new AssociatedBeanProperty();
63     }
64
65
66     /**
67      * Sets the stereotype of the search association.
68      * @param stereotype The stereotype.
69      */

70     public void setAssociatedClassWithStereotype(String JavaDoc stereotype) {
71         associatedClassWithStereotype = stereotype;
72     }
73
74
75     /**
76      * Sets the stereotype of the class associated by the search association.
77      * @param stereotype The stereotype.
78      */

79     public void setAssociatedClassHasStereotype(String JavaDoc stereotype) {
80         associatedClassHasStereotype = stereotype;
81     }
82
83
84     /**
85      * Sets the type of the search association.
86      * @param type The type.
87      */

88     public void setAssociatedClassWithType(String JavaDoc type) {
89         associatedClassWithType = type;
90     }
91   
92     
93     private class AssociatedBeanProperty extends BeanProperty {
94         /* (non-Javadoc)
95          * @see ispuml.mdaTransformation.rules.xml.Property#getValue(java.lang.Object, ispuml.mdaTransformation.RuleContext)
96          */

97         public Object JavaDoc getValue(Object JavaDoc object, RuleContext context) throws TransformationException {
98             Object JavaDoc bean = super.getValue(object, context);
99             if (associatedClassWithType != null)
100                 return assoClassUtils.getAssociatedClass(bean, associatedClassWithType, context.engineContext.getModel(object));
101             else
102                 return assoClassUtils.getAssociatedClass(bean, associatedClassWithStereotype, associatedClassHasStereotype, context.engineContext.getModel(object));
103         }
104     }
105
106 }
107
Popular Tags