KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jfun > yan > ComponentMap


1 /*****************************************************************************
2  * Copyright (C) Codehaus.org. All rights reserved. *
3  * ------------------------------------------------------------------------- *
4  * The software in this package is published under the terms of the BSD *
5  * style license a copy of which has been included with this distribution in *
6  * the LICENSE.txt file. *
7  *****************************************************************************/

8 /*
9  * Created on Mar 1, 2005
10  *
11  * Author Ben Yu
12  * ZBS
13  */

14 package jfun.yan;
15
16
17 /**
18  * A map that is used to retrieve Component by key or type.
19  * <p>
20  * Codehaus.org.
21  *
22  * @author Ben Yu
23  *
24  */

25 public interface ComponentMap extends java.io.Serializable JavaDoc{
26   /**
27    * Gets a Component identified by a key.
28    * @param key the component key.
29    * @return the Component object
30    * or null if a component with the given key is not found.
31    */

32   Component getComponent(Object JavaDoc key);
33   /**
34    * Get all the component keys.
35    * @return the component keys.
36    */

37   java.util.Set JavaDoc keys();
38   /**
39    * Gets all components stored in this map.
40    * @return the components.
41    * The returned Collection contains 0 or more Component objects.
42    */

43   java.util.Collection JavaDoc getComponents();
44
45   /**
46    * Gets a Component object of a certain type.
47    * Subtype relationship is honored. So that a Component with type String
48    * is considered with type CharSequence as well.
49    * If more than one Component is found with the given type,
50    * AmbiguousComponentResolutionException is thrown.
51    * null is returned if no such component is found.
52    * @param type the component instance type.
53    * @return the Component object.
54    * @throws AmbiguousComponentResolutionException
55    */

56   <T> Component<T> getComponentOfType(Class JavaDoc<T> type)
57   throws AmbiguousComponentResolutionException;
58   /**
59    * Whether a Component with a certain key is contained in the map.
60    * @param key the component key.
61    * @return true if the key exists in the map.
62    */

63   boolean containsKey(Object JavaDoc key);
64   /**
65    * Whether a Component of a certain type or its sub-type is contained in the map.
66    * @param type the type of the component.
67    * @return true if the type or its sub-type exists in the map.
68    */

69   boolean containsType(Class JavaDoc type);
70   /**
71    * Gets all component objects that are of a certain type.
72    * @param type the component instance type.
73    * @return the list of the components with this type.
74    */

75   <T> java.util.List JavaDoc<Component<T>> getComponentsOfType(Class JavaDoc<T> type);
76   /**
77    * Gets the Dependency object for a component key.
78    * @param key The component key.
79    * @param cmap The ComponentMap object from which the parts of
80    * the component should be obtained.
81    * This parameter is typically passed as 'this' so that the parts are
82    * created in the same container.
83    * When implementing container interaction such as inheritance,
84    * this parameter may be passed as a different ComponentMap object.
85    * @return the Dependency object.
86    */

87   Dependency getDependency(Object JavaDoc key, ComponentMap cmap);
88   /**
89    * Gets the Dependency object for a component instance type.
90    * @param type The component instance type.
91    * @param cmap The ComponentMap object from which the parts of
92    * the component should be obtained.
93    * This parameter is typically passed as 'this' so that the parts are
94    * created in the same container.
95    * When implementing container interaction such as inheritance,
96    * this parameter may be passed as a different ComponentMap object.
97    * @return the Dependency object.
98    */

99   Dependency getDependencyOfType(Class JavaDoc type, ComponentMap cmap);
100 }
101
Popular Tags