001    /*
002      Copyright (C) 2002 Renaud Pawlak <renaud@aopsys.com>
003    
004      This program is free software; you can redistribute it and/or modify
005      it under the terms of the GNU Lesser General Public License as
006      published by the Free Software Foundation; either version 2 of the
007      License, or (at your option) any later version.
008    
009      This program is distributed in the hope that it will be useful,
010      but WITHOUT ANY WARRANTY; without even the implied warranty of
011      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
012      GNU Lesser General Public License for more details.
013    
014      You should have received a copy of the GNU Lesser General Public
015      License along with this program; if not, write to the Free Software
016      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
017      USA */
018    
019    package org.objectweb.jac.ide;
020    
021    import java.util.List;
022    import java.util.Vector;
023    
024    /**
025     * This is the root class of all the model elements. */
026    
027    public abstract class ModelElement{
028    
029        /**
030         * Builds an unamed model element. */
031        public ModelElement(){
032        }
033    
034        /**
035         * Builds a named model element. */
036        public ModelElement(String name){
037            this.name = name;
038        }
039    
040        String name = "";
041    
042        /** Sets the model element name. */
043        public void setName(String name){
044            this.name = name;
045        }
046       
047        /**
048         * Defines a redefinable method to get the full name. Here it is
049         * equivalent to the <code>getName()</code> method. */
050    
051        public String getFullName(){
052            return getName();
053        }
054    
055        /** Gets the model element name. */
056        public String getName(){
057            return name;
058        }
059    
060        /**
061         * Gets name to use for code generation. Defaults to name.
062         */
063        public String getGenerationName() {
064            return getName();
065        }
066    
067        /**
068         * Gets full name to use for code generation. Defaults to fullName.
069         */
070        public String getGenerationFullName() {
071            return getFullName();
072        }
073    
074        /**
075         * Get the type of the model element.
076         *
077         * @return the void type (by default, element are not typed) */
078    
079        public Type getType(){
080            return Projects.types.resolveType("void", "");
081        }
082    
083        List endingLinks = new Vector();
084        /**
085         * Gets the list of the links that end on this model element.
086         * @return value of endingLinks.
087         * @see Link
088         */
089        public List getEndingLinks(){
090            return endingLinks;
091        }
092        /** Sets the ending links list. */
093        public void setEndingLinks(List l) {
094            endingLinks = l;
095        }   
096        /** Adds a link that ends on this element. */
097        public void addEndingLink(Role l) {
098            endingLinks.add(l);
099        }
100        /** Removes an ending link. */
101        public void removeEndingLink(Role l) {
102            endingLinks.remove(l);
103        }
104    
105        List links = new Vector();
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 getLinks() {
112            return links;
113        }
114        /** Sets the ending links list. */
115        public void setLinks(List 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 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 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 v){
142            this.description=v;
143    
144        }
145    
146        private List configItems = new Vector();
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 getConfigItems(){
165            return configItems;
166        }
167    }