Skip to main content
summaryrefslogtreecommitdiffstats
blob: 75057c0eba819333950be62be9efbb9250057172 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
/*******************************************************************************
 * Copyright (c) 2000, 2005 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/

package org.eclipse.wst.ws.internal.datamodel;

import java.util.Enumeration;

/**
* This is the abstract class for elements that can be managed by a Model.
* Every element has a name, a set of properties, and a set of relationships
* to other elements.
*/
public interface Element
{

  // Copyright
  public static final String copyright = "(c) Copyright IBM Corporation 2000, 2002.";

  /**
  * Returns a clone of this <code>Element</code>
  * of the same class and with the same name and model,
  * but with no Properties, Rels or Listeners except for
  * the {@link Property#NAME NAME} property.
  * @return Object A new Element.
  */
  public Element shallowClone ();

  /**
  * Returns a clone of this <code>Element</code>
  * of the same class and with the same name and model
  * and with a copy of the original Element's Properties.
  * The Rels and Listeners are not cloned.
  * @return Element A new Element.
  */
  public Element deepClone ();

  /**
  * Returns the model this element belongs to, or null if the element
  * has not been added to a model. See also {@link #isValid isValid()}.
  * @return Model The model this element belongs to, or null if none.
  */
  public Model getModel ();

  /**
  * Returns true if and only if this element belongs to a model.
  * See also {@link #getModel getModel()}.
  * @return boolean True if and only if this element belongs to a model.
  */
  public boolean isValid ();

  /**
  * Removes this element from the model to which it currently belongs.
  * After calling this method, {@link #getModel getModel()} will return
  * null and {@link #isValid isValid()} will return false.
  * @return boolean True if the element was successfully removed from
  * its model. This method returns false if the element does not belong
  * to any model.
  */
  public boolean remove ();

  /**
  * Sets the name of this element and updates the "name" property.
  * Every element includes a property called "name" (see Property.NAME)
  * whose value is the same string as passed into setName().
  * @param name The name of this element.
  */
  public void setName ( String name );

  /**
  *
  */
  public void addListener ( ElementListener listener );

  /**
  * Returns the name of this element.
  * @return String The name of this element.
  */
  public String getName ();

  /**
  * Adds or sets a property of this element.
  * Properties set using this method can be retrieved using either
  * {@link #getProperty getProperty()} or
  * {@link #getPropertyAsObject getPropertyAsObject()}.
  * Every element includes a property called "name" (see Property.NAME)
  * whose value is the same string as passed into {@link #setName setName()}.
  * Any previous property with the same name is replaced.
  * @param property The property to set.
  */
  public void setProperty ( Property property );

  /**
  * Adds or sets a property of this element.
  * Properties set using this method can be retrieved using either
  * {@link #getProperty getProperty()} or
  * {@link #getPropertyAsObject getPropertyAsObject()}.
  * Every element includes a property called "name" (see Property.NAME)
  * whose value is the same string as passed into {@link #setName setName()}.
  * Any previous property with the same name is replaced.
  * @param name The name of the property to set.
  * @param value The Object value of the property to set.
  */
  public void setPropertyAsObject ( String name, Object value );

  /**
  * Adds or sets a String property of this element.
  * Properties set using this method can be retrieved using either
  * {@link #getProperty getProperty()},
  * {@link #getPropertyAsObject getPropertyAsObject()} or
  * {@link #getPropertyAsString getPropertyAsString()}.
  * Every element includes a property called "name" (see Property.NAME)
  * whose value is the same string as passed into {@link #setName setName()}.
  * Any previous property with the same name is replaced.
  * @param name The name of the property to set.
  * @param value The String value of the property to set.
  */
  public void setPropertyAsString ( String name, String value );

  /**
  * Returns a property of the given name or null if there is none.
  * Every element includes a property called "name" (see Property.NAME)
  * whose value is the same string as passed into {@link #setName setName()}.
  * @param name The name of the property to return.
  * @return Property The property, or null if none.
  */
  public Property getProperty ( String name );

  /**
  * Returns the Object value of a property of the given name or null
  * if there is none.
  * Every element includes a property called "name" (see Property.NAME)
  * whose value is the same string as passed into {@link #setName setName()}.
  * @param name The name of the property to return.
  * @return Object The property value as an Object, or null if none.
  */
  public Object getPropertyAsObject ( String name );

  /**
  * Returns the String value of a property of the given name or null
  * if there is none.
  * Every element includes a property called "name" (see Property.NAME)
  * whose value is the same string as passed into {@link #setName setName()}.
  * @param name The name of the property to return.
  * @return String The property value as a String, or null if none.
  */
  public String getPropertyAsString ( String name );

  /**
  * Returns an enumeration of all properties of this element.
  * There is always at least one property that carries the
  * name of this element (see {@link #setName setName()}).
  * @return Enumeration An enumeration of all properties of this element.
  */
  public Enumeration getProperties ();

  /**
  * Creates a bidirectional relationship between this element and another.
  * Both relationships are identified by names. The names of all the
  * outbound relationships of a element must be mutually unique.
  * @param element The element to connect to.
  * @param outboundRelName The name of the relationship to contain the
  * connection to the element.
  * @param inboundRelName The name of the relationship to contain the
  * inverse connection back to this element.
  * @return boolean True if the connection is created successfully.
  * Both elements must belong to the same model, other false is returned.
  */
  public boolean connect ( Element element, String outboundRelName, String inboundRelName );

  /**
  * Dismantles the connection to another element in a given relationship.
  * The inverse connection is also automatically dismantled.
  * @param element The element to disconnect from.
  * @param outboundRelName The name of the relationship containing
  * the connection to the element.
  * @return boolean True if the connection is removed successfully.
  * Both elements must belong to the same model, other false is returned.
  * If the elements are not connected through the given relationship, then
  * false is returned.
  */
  public boolean disconnect ( Element element, String outboundRelName );

  /**
  * Dismantles the connection to all elements in the given relationship.
  * The inverse connections are also automatically dismantled.
  * @param outboundRelName The name of the relationship.
  * @return boolean True if all connections are removed successfully.
  * This method returns false if the element does not belong to a model.
  */
  public boolean disconnectRel ( String outboundRelName );

  /**
  * Dismantles all connections from this element.
  * @return boolean True if all connections are removed successfully.
  * This method returns false if the element does not belong to a model.
  */
  public boolean disconnectAll ();

  /**
  * Returns an enumeration of all elements
  * connected thru the given relationship.
  * @param relName The name of the relationship.
  * @return Enumeration The elements in the relationship.
  * This method never returns null.
  */
  public Enumeration getElements ( String relName );

  /**
  * Returns the number of elements in the given relationship.
  * @param relName The name of the relationship.
  * @return int The number of elements in the relationship.
  * This method never returns a negative value.
  */

  public Enumeration getListeners();

  public int getNumberOfElements ( String relName );

  /**
  * Returns the relationship object of the given name.
  * @param relName The name of the relationship.
  * @return int The relationship. This method never returns null.
  * In other words, any reference to a relationship name automatically
  * brings a corresponding Rel object into existence. Careless naming
  * may result in the {@link #getRels getRels()} method returning an enumeration of
  * more relationships than would be meaningful, efficient or useful.
  */
  public Rel getRel ( String relName );

  /**
  * Returns an enumeration of all known relationships.
  * @return Enumeration The outbound relationships of the element.
  * This method never returns null.
  */
  public Enumeration getRels ();


  /*
  * There is a need sometimes for each element in a model to have a unique identifier.
  * Normally this would be left to a name, but since the element maker gives it its name
  * there is a chance that a model could have two elements with the same name. If they 
  * are the same element type then there would be no way to differenciate between the two.
  * The following getter and setter will provide a unique identifier. This identifier will be known 
  * as the muid or Model Unique Identifier. Unlike a uuid it will only be assured uniqueness 
  * within its own model. The intention is to use a unique number appended to the end 
  * of the name.
  * The following is the getter
  * @return String the unique identifier
  */

  public String getMUID();
  
  


}

Back to the top