KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > fractal > gui > model > Component


1 /***
2  * FractalGUI: a graphical tool to edit Fractal component configurations.
3  * Copyright (C) 2003 France Telecom R&D
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Contact: fractal@objectweb.org
20  *
21  * Authors: Eric Bruneton, Patrice Fauvel
22  */

23
24 package org.objectweb.fractal.gui.model;
25
26 import java.util.List JavaDoc;
27
28 /**
29  * A primitive or composite component.
30  */

31
32 public interface Component {
33
34   /**
35    * The {@link #getStatus status} flags corresponding to a valid component.
36    */

37
38   long OK = 0;
39
40   /**
41    * A {@link #getStatus status} flag indicating that the component's name is
42    * missing.
43    */

44
45   long NAME_MISSING = 1;
46
47   /**
48    * A {@link #getStatus status} flag indicating that the component's type is
49    * missing.
50    */

51
52   // long TYPE_MISSING = 1 << 1;
53

54   /**
55    * A {@link #getStatus status} flag indicating that the component's
56    * implementation is missing.
57    */

58
59   long IMPLEMENTATION_MISSING = 1 << 2;
60
61   /**
62    * A {@link #getStatus status} flag indicating that the component's
63    * implementation class cannot be found.
64    */

65
66   long IMPLEMENTATION_CLASS_NOT_FOUND = 1 << 3;
67
68   /**
69    * A {@link #getStatus status} flag indicating that the component's
70    * implementation class is invalid.
71    */

72
73   long IMPLEMENTATION_CLASS_INVALID = 1 << 4; // TODO gerer ce type d'erreur
74

75   /**
76    * A {@link #getStatus status} flag indicating that the component's interfaces
77    * are invalid.
78    */

79
80   long INTERFACES_INVALID = 1 << 5;
81
82   /**
83    * A {@link #getStatus status} flag indicating that the component's attribute
84    * controller interface is missing.
85    */

86
87   long ATTRIBUTE_CONTROLLER_MISSING = 1 << 6;
88
89   /**
90    * A {@link #getStatus status} flag indicating that the component's attribute
91    * controller interface cannot be found.
92    */

93
94   long ATTRIBUTE_CONTROLLER_CLASS_NOT_FOUND = 1 << 7;
95
96   /**
97    * A {@link #getStatus status} flag indicating that the component's attribute
98    * controller interface is invalid.
99    */

100
101   long ATTRIBUTE_CONTROLLER_CLASS_INVALID = 1 << 8; // TODO gerer ce type d'erreur
102

103   // -------------------------------------------------------------------------
104
// Configuration
105
// -------------------------------------------------------------------------
106

107   /**
108    * Returns the configuration to which this component belongs.
109    *
110    * @return the configuration to which this component belongs.
111    */

112
113   Configuration getConfiguration();
114
115
116   // -------------------------------------------------------------------------
117
// Status
118
// -------------------------------------------------------------------------
119

120   /**
121    * Returns the status of this component.
122    *
123    * @return the status flags of this component. Each flag, i.e., each bit of
124    * the returned value is independent from the other, and indicates an
125    * error if it is set.
126    * @see #setStatus
127    */

128
129   long getStatus ();
130
131   /**
132    * Sets the status of this component. <i>This method is reserved for model
133    * providers, and must not be called by model users</i>.
134    *
135    * @param status the new status of this component.
136    * @see #getStatus
137    */

138
139   void setStatus (long status);
140
141   // -------------------------------------------------------------------------
142
// Ancestors
143
// -------------------------------------------------------------------------
144

145   /**
146    * Returns the parent component of this component.
147    *
148    * @return the parent component of this component, or <tt>null</tt> if this
149    * component is the root component.
150    */

151
152   Component getParent ();
153
154   /**
155    * Returns the root component of the configuration. This method just calls
156    * {@link #getParent getParent} until the root component is found.
157    *
158    * @return the root component of the configuration.
159    */

160
161   Component getRootComponent ();
162
163   /**
164    * Returns the path of this component from the root component.
165    *
166    * @return an ordered array of all the ancestors of this component, from the
167    * root component to this component, included.
168    */

169
170   Object JavaDoc[] getPath ();
171
172   // -------------------------------------------------------------------------
173
// Name, Type, Implementation
174
// -------------------------------------------------------------------------
175

176   /**
177    * Returns the name of this component.
178    *
179    * @return the name of this component.
180    * @see #setName
181    */

182
183   String JavaDoc getName ();
184
185   /**
186    * Sets the name of this component. This method notifies the configuration
187    * listeners, via the {@link ConfigurationListener#nameChanged nameChanged}
188    * method.
189    *
190    * @param name the new component name.
191    * @see #getName
192    */

193
194   void setName (String JavaDoc name);
195
196   /**
197    * Returns the type of this component.
198    *
199    * @return the type of this component.
200    * @see #setType
201    */

202
203   String JavaDoc getType ();
204
205   /**
206    * Sets the type of this component. This method notifies the configuration
207    * listeners, via the {@link ConfigurationListener#typeChanged typeChanged}
208    * method.
209    *
210    * @param type the new component type.
211    * @see #getType
212    */

213
214   void setType (String JavaDoc type);
215
216   /**
217    * Returns the implementation of this component.
218    *
219    * @return the implementation of this component.
220    * @see #setImplementation
221    */

222
223   String JavaDoc getImplementation ();
224
225   /**
226    * Sets the implementation of this component. This method notifies the
227    * configuration listeners, via the {@link
228    * ConfigurationListener#implementationChanged implementationChanged} method.
229    *
230    * @param implementation the new component implementation.
231    * @see #getImplementation
232    */

233
234   void setImplementation (String JavaDoc implementation);
235
236   // -------------------------------------------------------------------------
237
// Client and Server interfaces
238
// -------------------------------------------------------------------------
239

240   /**
241    * Returns the external client interfaces of this component.
242    *
243    * @return an unmodifiable list of {@link ClientInterface} objects
244    * corresponding to the external client interfaces of this component.
245    */

246
247   List JavaDoc getClientInterfaces ();
248
249   /**
250    * Returns the external client interface of this component whose name is
251    * given.
252    *
253    * @param name the name of the interface that must be returned.
254    * @return the external client interface of this component whose name is
255    * given, or <tt>null</tt> if there is no such interface.
256    */

257
258   Interface getClientInterface (String JavaDoc name);
259
260   /**
261    * Adds the given client interface to this component. Does nothing if the
262    * given interface already belongs to this component. This method notifies the
263    * configuration listeners, via the {@link
264    * ConfigurationListener#clientInterfaceAdded clientInterfaceAdded} method.
265    *
266    * @param itf the interface that must be added to this component. This
267    * interface must have been created for this specific component (see
268    * {@link Factory#createClientInterface createClientInterface}).
269    */

270
271   void addClientInterface (ClientInterface itf);
272
273   /**
274    * Removes the given client interface from this component. Does nothing if the
275    * given interface does not belong to this component. This method notifies the
276    * configuration listeners, via the {@link
277    * ConfigurationListener#clientInterfaceRemoved clientInterfaceRemoved}
278    * method.
279    *
280    * @param itf the interface that must be removed from this component.
281    */

282
283   void removeClientInterface (ClientInterface itf);
284
285   /**
286    * Returns the external server interfaces of this component.
287    *
288    * @return an unmodifiable list of {@link ServerInterface}
289    * objects corresponding to the external server interfaces of this
290    * component.
291    */

292
293   List JavaDoc getServerInterfaces ();
294
295   /**
296    * Returns the external server interface of this component whose name is
297    * given.
298    *
299    * @param name the name of the interface that must be returned.
300    * @return the external server interface of this component whose name is
301    * given, or <tt>null</tt> if there is no such interface.
302    */

303
304   Interface getServerInterface (String JavaDoc name);
305
306   /**
307    * Adds the given server interface to this component. Does nothing if the
308    * given interface already belongs to this component. This method notifies the
309    * configuration listeners, via the {@link
310    * ConfigurationListener#serverInterfaceAdded serverInterfaceAdded} method.
311    *
312    * @param itf the interface that must be added to this component. This
313    * interface must have been created for this specific component (see
314    * {@link Factory#createServerInterface createServerInterface}).
315    */

316
317   void addServerInterface (ServerInterface itf);
318
319   /**
320    * Removes the given server interface from this component. Does nothing if the
321    * given interface does not belong to this component. This method notifies the
322    * configuration listeners, via the {@link
323    * ConfigurationListener#serverInterfaceRemoved serverInterfaceRemoved}
324    * method.
325    *
326    * @param itf the interface that must be removed from this component.
327    */

328
329   void removeServerInterface (ServerInterface itf);
330
331   // -------------------------------------------------------------------------
332
// Bindings
333
// -------------------------------------------------------------------------
334

335   /**
336    * Binds the given client interface to the given server interface. This method
337    * notifies the configuration listeners, via the {@link
338    * ConfigurationListener#interfaceBound interfaceBound} method.
339    *
340    * @param citf a client interface of this component.
341    * @param sitf a server interface.
342    */

343
344   void bind (ClientInterface citf, String JavaDoc suffix, ServerInterface sitf);
345
346   /**
347    * Rebinds the given client interface to the given server interface. This
348    * method notifies the configuration listeners, via the {@link
349    * ConfigurationListener#interfaceRebound interfaceRebound} method.
350    *
351    * @param citf a client interface of this component.
352    * @param sitf a server interface.
353    */

354
355   void rebind (ClientInterface citf, ServerInterface sitf);
356
357   /**
358    * Unbinds the given client interface. This method notifies the configuration
359    * listeners, via the {@link ConfigurationListener#interfaceUnbound
360    * interfaceUnbound} method.
361    *
362    * @param citf a client interface of this component.
363    */

364
365   void unbind (ClientInterface citf);
366
367   // -------------------------------------------------------------------------
368
// Attributes
369
// -------------------------------------------------------------------------
370

371   /**
372    * Returns the name of the attribute controller interface of this component.
373    *
374    * @return the name of the attribute controller interface of this component.
375    * @see #setAttributeController
376    */

377
378   String JavaDoc getAttributeController ();
379
380   /**
381    * Sets the name of the attribute controller interface of this component.
382    * This method notifies the configuration listeners, via the {@link
383    * ConfigurationListener#attributeControllerChanged
384    * attributeControllerChanged} method.
385    *
386    * @param attributeController the new attribute controller interface name.
387    * @see #getAttributeController
388    */

389
390   void setAttributeController (String JavaDoc attributeController);
391
392   /**
393    * Returns the names of the attributes of this component.
394    *
395    * @return an unmodifiable list of String objects corresponding to the names
396    * of the attributes of this component.
397    */

398
399   List JavaDoc getAttributeNames ();
400
401   /**
402    * Return the value of the given attribute of this component.
403    *
404    * @param attributeName the name of an attribute of this component.
405    * @return the value of the given attribute, or <tt>null</tt> if this
406    * attribute does not exist.
407    * @see #setAttribute
408    */

409
410   String JavaDoc getAttribute (String JavaDoc attributeName);
411
412   /**
413    * Sets the value of an attribute of this component. This method notifies the
414    * configuration listeners, via the {@link
415    * ConfigurationListener#attributeChanged attributeChanged} method.
416    *
417    * @param attributeName the name of an existing or of a new attribute of this
418    * component.
419    * @param attributeValue the new value of this attribute.
420    * @see #getAttribute
421    */

422
423   void setAttribute (String JavaDoc attributeName, String JavaDoc attributeValue);
424
425   // -------------------------------------------------------------------------
426
// Controller descriptors
427
// -------------------------------------------------------------------------
428

429   /**
430    * Returns the template controller descriptor of this component.
431    *
432    * @return the template controller descriptor of this component.
433    * @see #setTemplateControllerDescriptor
434    */

435
436   String JavaDoc getTemplateControllerDescriptor ();
437
438   /**
439    * Sets the template controller descriptor of this component. This method
440    * notifies the configuration listeners, via the {@link
441    * ConfigurationListener#templateControllerDescriptorChanged
442    * templateControllerDescriptorChanged} method.
443    *
444    * @param desc the new template controller descriptor of this component.
445    * @see #getTemplateControllerDescriptor
446    */

447
448   void setTemplateControllerDescriptor (String JavaDoc desc);
449
450   /**
451    * Returns the component controller descriptor of this component.
452    *
453    * @return the component controller descriptor of this component.
454    * @see #setComponentControllerDescriptor
455    */

456
457   String JavaDoc getComponentControllerDescriptor ();
458
459   /**
460    * Sets the component controller descriptor of this component. This method
461    * notifies the configuration listeners, via the {@link
462    * ConfigurationListener#componentControllerDescriptorChanged
463    * componentControllerDescriptorChanged} method.
464    *
465    * @param desc the new component controller descriptor of this component.
466    * @see #getComponentControllerDescriptor
467    */

468
469   void setComponentControllerDescriptor (String JavaDoc desc);
470
471   // -------------------------------------------------------------------------
472
// Sharing
473
// -------------------------------------------------------------------------
474

475   /**
476    * Returns <tt>true</tt> if this component has slave component.
477    *
478    * @return <tt>true</tt> if the {@link #getSlaveComponents getSlaveComponent}
479    * list is empty.
480    */

481
482   boolean isShared ();
483
484   /**
485    * Returns the master component of this component.
486    *
487    * @return the master component of this component, or <tt>null</tt> if this
488    * component is not a slave component.
489    */

490
491   Component getMasterComponent ();
492
493   /**
494    * Returns the slave components of this component.
495    *
496    * @return an unmodifiable list of {@link Component Component} objects that
497    * correspond to the slave components of this component. This list is
498    * empty is this component is not a master component.
499    */

500
501   List JavaDoc getSlaveComponents ();
502
503   // -------------------------------------------------------------------------
504
// Composite specific informations
505
// -------------------------------------------------------------------------
506

507   /**
508    * Returns <tt>true</tt> if this component is a composite component.
509    *
510    * @return <tt>true</tt> if the {@link #getSubComponents getSubComponents}
511    * list is empty.
512    */

513
514   boolean isComposite ();
515
516   /**
517    * Returns <tt>true</tt> if this component contains the given sub component.
518    *
519    * @param child a component.
520    * @return <tt>true</tt> if this component contains the given sub component.
521    */

522
523   boolean contains (Component child);
524
525   /**
526    * Returns <tt>true</tt> if the given component contains a slave component
527    * but does not contain its master.
528    *
529    * @param root a component.
530    * @return <tt>true</tt> if the given component contains a slave component
531    * but does not contain its master.
532    */

533
534   boolean containsSlaveOfExternalComponent (Component root);
535
536   /**
537    * Returns <tt>true</tt> if the given component contains a master component
538    * but does not contain all its slaves.
539    *
540    * @param root a component.
541    * @return <tt>true</tt> if the given component contains a master component
542    * but does not contain all its slaves.
543    */

544
545   boolean containsMasterOfExternalComponent (Component root);
546
547   /**
548    * Returns the sub components of this component.
549    *
550    * @return an unmodifiable list of {@link Component} objects that correspond
551    * to the sub components of this component. This list is empty if this
552    * component is a primitive component.
553    */

554
555   List JavaDoc getSubComponents ();
556
557   /**
558    * Returns the sub component of this component whose name is given.
559    *
560    * @param name the name of a sub component of this component.
561    * @return the sub component of this component whose name is given, or
562    * <tt>null</tt> if there is no such sub component.
563    */

564
565   Component getSubComponent (String JavaDoc name);
566
567   /**
568    * Adds the given component as a sub component of this component. Does nothing
569    * if the given component is already a sub component of this component. This
570    * method notifies the configuration listeners, via the {@link
571    * ConfigurationListener#subComponentAdded subComponentAdded} method.
572    *
573    * @param child a component.
574    */

575
576   void addSubComponent (Component child);
577
578   /**
579    * Removes the given sub component from this component. Does nothing if the
580    * given component is not a sub component of this component. This
581    * method notifies the configuration listeners, via the {@link
582    * ConfigurationListener#subComponentRemoved subComponentRemoved} method.
583    *
584    * @param child a sub component of this component.
585    */

586
587   void removeSubComponent (Component child);
588 }
589
Popular Tags