KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > repo > dictionary > M2Class


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.repo.dictionary;
18
19 import java.util.ArrayList JavaDoc;
20 import java.util.Collections JavaDoc;
21 import java.util.List JavaDoc;
22
23 /**
24  * Abstract Class Definition.
25  *
26  * @author David Caruana
27  *
28  */

29 public abstract class M2Class
30 {
31     private String JavaDoc name = null;
32     private String JavaDoc title = null;
33     private String JavaDoc description = null;
34     private String JavaDoc parentName = null;
35     
36     private List JavaDoc<M2Property> properties = new ArrayList JavaDoc<M2Property>();
37     private List JavaDoc<M2PropertyOverride> propertyOverrides = new ArrayList JavaDoc<M2PropertyOverride>();
38     private List JavaDoc<M2ClassAssociation> associations = new ArrayList JavaDoc<M2ClassAssociation>();
39     private List JavaDoc<String JavaDoc> mandatoryAspects = new ArrayList JavaDoc<String JavaDoc>();
40
41     /*package*/ M2Class()
42     {
43     }
44
45     
46     public String JavaDoc getName()
47     {
48         return name;
49     }
50
51     
52     public void setName(String JavaDoc name)
53     {
54         this.name = name;
55     }
56
57     
58     public String JavaDoc getTitle()
59     {
60         return title;
61     }
62     
63     
64     public void setTitle(String JavaDoc title)
65     {
66         this.title = title;
67     }
68     
69     
70     public String JavaDoc getDescription()
71     {
72         return description;
73     }
74     
75     
76     public void setDescription(String JavaDoc description)
77     {
78         this.description = description;
79     }
80
81     
82     public String JavaDoc getParentName()
83     {
84         return parentName;
85     }
86     
87     
88     public void setParentName(String JavaDoc parentName)
89     {
90         this.parentName = parentName;
91     }
92     
93     
94     public M2Property createProperty(String JavaDoc name)
95     {
96         M2Property property = new M2Property();
97         property.setName(name);
98         properties.add(property);
99         return property;
100     }
101     
102     
103     public void removeProperty(String JavaDoc name)
104     {
105         M2Property property = getProperty(name);
106         if (property != null)
107         {
108             properties.remove(property);
109         }
110     }
111
112
113     public List JavaDoc<M2Property> getProperties()
114     {
115         return Collections.unmodifiableList(properties);
116     }
117
118     
119     public M2Property getProperty(String JavaDoc name)
120     {
121         for (M2Property candidate : properties)
122         {
123             if (candidate.getName().equals(name))
124             {
125                 return candidate;
126             }
127         }
128         return null;
129     }
130
131     
132     public M2Association createAssociation(String JavaDoc name)
133     {
134         M2Association association = new M2Association();
135         association.setName(name);
136         associations.add(association);
137         return association;
138     }
139
140     
141     public M2ChildAssociation createChildAssociation(String JavaDoc name)
142     {
143         M2ChildAssociation association = new M2ChildAssociation();
144         association.setName(name);
145         associations.add(association);
146         return association;
147     }
148     
149     
150     public void removeAssociation(String JavaDoc name)
151     {
152         M2ClassAssociation association = getAssociation(name);
153         if (association != null)
154         {
155             associations.remove(association);
156         }
157     }
158
159     
160     public List JavaDoc<M2ClassAssociation> getAssociations()
161     {
162         return Collections.unmodifiableList(associations);
163     }
164
165     
166     public M2ClassAssociation getAssociation(String JavaDoc name)
167     {
168         for (M2ClassAssociation candidate : associations)
169         {
170             if (candidate.getName().equals(name))
171             {
172                 return candidate;
173             }
174         }
175         return null;
176     }
177     
178     
179     public M2PropertyOverride createPropertyOverride(String JavaDoc name)
180     {
181         M2PropertyOverride property = new M2PropertyOverride();
182         property.setName(name);
183         propertyOverrides.add(property);
184         return property;
185     }
186     
187     
188     public void removePropertyOverride(String JavaDoc name)
189     {
190         M2PropertyOverride property = getPropertyOverride(name);
191         if (property != null)
192         {
193             propertyOverrides.remove(property);
194         }
195     }
196
197     
198     public List JavaDoc<M2PropertyOverride> getPropertyOverrides()
199     {
200         return Collections.unmodifiableList(propertyOverrides);
201     }
202
203
204     public M2PropertyOverride getPropertyOverride(String JavaDoc name)
205     {
206         for (M2PropertyOverride candidate : propertyOverrides)
207         {
208             if (candidate.getName().equals(name))
209             {
210                 return candidate;
211             }
212         }
213         return null;
214     }
215     
216     public void addMandatoryAspect(String JavaDoc name)
217     {
218         mandatoryAspects.add(name);
219     }
220     
221     
222     public void removeMandatoryAspect(String JavaDoc name)
223     {
224         mandatoryAspects.remove(name);
225     }
226     
227
228     public List JavaDoc<String JavaDoc> getMandatoryAspects()
229     {
230         return Collections.unmodifiableList(mandatoryAspects);
231     }
232     
233 }
234
Popular Tags