KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jac > ide > ModelElement


1 /*
2   Copyright (C) 2002 Renaud Pawlak <renaud@aopsys.com>
3
4   This program is free software; you can redistribute it and/or modify
5   it under the terms of the GNU Lesser General Public License as
6   published by the Free Software Foundation; either version 2 of the
7   License, or (at your option) any later version.
8
9   This program is distributed in the hope that it will be useful,
10   but WITHOUT ANY WARRANTY; without even the implied warranty of
11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12   GNU Lesser General Public License for more details.
13
14   You should have received a copy of the GNU Lesser General Public
15   License along with this program; if not, write to the Free Software
16   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17   USA */

18
19 package org.objectweb.jac.ide;
20
21 import java.util.List JavaDoc;
22 import java.util.Vector JavaDoc;
23
24 /**
25  * This is the root class of all the model elements. */

26
27 public abstract class ModelElement{
28
29     /**
30      * Builds an unamed model element. */

31     public ModelElement(){
32     }
33
34     /**
35      * Builds a named model element. */

36     public ModelElement(String JavaDoc name){
37         this.name = name;
38     }
39
40     String JavaDoc name = "";
41
42     /** Sets the model element name. */
43     public void setName(String JavaDoc name){
44         this.name = name;
45     }
46    
47     /**
48      * Defines a redefinable method to get the full name. Here it is
49      * equivalent to the <code>getName()</code> method. */

50
51     public String JavaDoc getFullName(){
52         return getName();
53     }
54
55     /** Gets the model element name. */
56     public String JavaDoc getName(){
57         return name;
58     }
59
60     /**
61      * Gets name to use for code generation. Defaults to name.
62      */

63     public String JavaDoc getGenerationName() {
64         return getName();
65     }
66
67     /**
68      * Gets full name to use for code generation. Defaults to fullName.
69      */

70     public String JavaDoc getGenerationFullName() {
71         return getFullName();
72     }
73
74     /**
75      * Get the type of the model element.
76      *
77      * @return the void type (by default, element are not typed) */

78
79     public Type getType(){
80         return Projects.types.resolveType("void", "");
81     }
82
83     List JavaDoc endingLinks = new Vector JavaDoc();
84     /**
85      * Gets the list of the links that end on this model element.
86      * @return value of endingLinks.
87      * @see Link
88      */

89     public List JavaDoc getEndingLinks(){
90         return endingLinks;
91     }
92     /** Sets the ending links list. */
93     public void setEndingLinks(List JavaDoc l) {
94         endingLinks = l;
95     }
96     /** Adds a link that ends on this element. */
97     public void addEndingLink(Role l) {
98         endingLinks.add(l);
99     }
100     /** Removes an ending link. */
101     public void removeEndingLink(Role l) {
102         endingLinks.remove(l);
103     }
104
105     List JavaDoc links = new Vector JavaDoc();
106     /**
107      * Gets the list of the links that start from this model element.
108      * @return value of links.
109      * @see Link
110      */

111     public List JavaDoc getLinks() {
112         return links;
113     }
114     /** Sets the ending links list. */
115     public void setLinks(List JavaDoc l) {
116         links = l;
117     }
118     /** Adds a link that ends on this element. */
119     public void addLink(Role l) {
120         links.add(l);
121     }
122     /** Removes an ending link. */
123     public void removeLink(Role l) {
124         links.remove(l);
125     }
126
127     String JavaDoc description;
128
129     /**
130      * Gets the description of this element. All the model elements
131      * have a description for documentation.
132      * @return value of description. */

133     public String JavaDoc getDescription(){
134         return description;
135     }
136
137     /**
138      * Set the value of description.
139      * @param v Value to assign to description.
140      */

141     public void setDescription(String JavaDoc v){
142         this.description=v;
143
144     }
145
146     private List JavaDoc configItems = new Vector JavaDoc();
147
148     /**
149      * add a new ConfigItem on this Element
150      * @param config the new ConfigItem
151      */

152     public void addConfigItem(ConfigItem config){
153         configItems.add(config);
154     }
155
156     /**
157      * remove an ConfigItem
158      * @param config the ConfigItem
159      */

160     public void remove(ConfigItem config){
161         configItems.remove(config);
162     }
163
164     public List JavaDoc getConfigItems(){
165         return configItems;
166     }
167 }
168
Popular Tags