jfun.yan
Class DelegatingComponentMap

java.lang.Object
  extended by jfun.yan.DelegatingComponentMap
All Implemented Interfaces:
java.io.Serializable, ComponentMap

public class DelegatingComponentMap
extends java.lang.Object
implements ComponentMap

The base class for delegating to a ComponentMap object. It forwards all method call to the delegated ComponentMap object, which makes it handy for customizing a ComponentMap object by subclassing.

Codehaus.org.

Author:
Ben Yu
See Also:
Serialized Form

Constructor Summary
DelegatingComponentMap(ComponentMap cmap)
          Create new DelegatingComponentMap object.
 
Method Summary
 boolean containsKey(java.lang.Object key)
          Whether a Component with a certain key is contained in the map.
 boolean containsType(java.lang.Class type)
          Whether a Component of a certain type or its sub-type is contained in the map.
 boolean equals(java.lang.Object other)
           
 Component getComponent(java.lang.Object key)
          Gets a Component identified by a key.
 Component getComponentOfType(java.lang.Class type)
          Gets a Component object of a certain type.
 java.util.Collection getComponents()
          Gets all components stored in this map.
 java.util.List getComponentsOfType(java.lang.Class type)
          Gets all component objects that are of a certain type.
protected  ComponentMap getDelegateTarget()
          Gets the ComponentMap object being delegated.
 Dependency getDependency(java.lang.Object key, ComponentMap cmap)
          Gets the Dependency object for a component key.
 Dependency getDependencyOfType(java.lang.Class type, ComponentMap cmap)
          Gets the Dependency object for a component instance type.
 int hashCode()
           
 java.util.Set keys()
          Get all the component keys.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DelegatingComponentMap

public DelegatingComponentMap(ComponentMap cmap)
Create new DelegatingComponentMap object.

Parameters:
cmap - the ComponentMap object to delegate to.
Method Detail

containsKey

public boolean containsKey(java.lang.Object key)
Description copied from interface: ComponentMap
Whether a Component with a certain key is contained in the map.

Specified by:
containsKey in interface ComponentMap
Parameters:
key - the component key.
Returns:
true if the key exists in the map.

containsType

public boolean containsType(java.lang.Class type)
Description copied from interface: ComponentMap
Whether a Component of a certain type or its sub-type is contained in the map.

Specified by:
containsType in interface ComponentMap
Parameters:
type - the type of the component.
Returns:
true if the type or its sub-type exists in the map.

getDependencyOfType

public Dependency getDependencyOfType(java.lang.Class type,
                                      ComponentMap cmap)
Description copied from interface: ComponentMap
Gets the Dependency object for a component instance type.

Specified by:
getDependencyOfType in interface ComponentMap
Parameters:
type - The component instance type.
cmap - The ComponentMap object from which the parts of the component should be obtained. This parameter is typically passed as 'this' so that the parts are created in the same container. When implementing container interaction such as inheritance, this parameter may be passed as a different ComponentMap object.
Returns:
the Dependency object.

getDependency

public Dependency getDependency(java.lang.Object key,
                                ComponentMap cmap)
Description copied from interface: ComponentMap
Gets the Dependency object for a component key.

Specified by:
getDependency in interface ComponentMap
Parameters:
key - The component key.
cmap - The ComponentMap object from which the parts of the component should be obtained. This parameter is typically passed as 'this' so that the parts are created in the same container. When implementing container interaction such as inheritance, this parameter may be passed as a different ComponentMap object.
Returns:
the Dependency object.

getComponent

public Component getComponent(java.lang.Object key)
Description copied from interface: ComponentMap
Gets a Component identified by a key.

Specified by:
getComponent in interface ComponentMap
Parameters:
key - the component key.
Returns:
the Component object or null if a component with the given key is not found.

equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getDelegateTarget

protected final ComponentMap getDelegateTarget()
Gets the ComponentMap object being delegated.

Returns:
the ComponentMap object.

getComponentOfType

public Component getComponentOfType(java.lang.Class type)
Description copied from interface: ComponentMap
Gets a Component object of a certain type. Subtype relationship is honored. So that a Component with type String is considered with type CharSequence as well. If more than one Component is found with the given type, AmbiguousComponentResolutionException is thrown. null is returned if no such component is found.

Specified by:
getComponentOfType in interface ComponentMap
Parameters:
type - the component instance type.
Returns:
the Component object.

getComponentsOfType

public java.util.List getComponentsOfType(java.lang.Class type)
Description copied from interface: ComponentMap
Gets all component objects that are of a certain type.

Specified by:
getComponentsOfType in interface ComponentMap
Parameters:
type - the component instance type.
Returns:
the list of the components with this type.

getComponents

public java.util.Collection getComponents()
Description copied from interface: ComponentMap
Gets all components stored in this map.

Specified by:
getComponents in interface ComponentMap
Returns:
the components. The returned Collection contains 0 or more Component objects.

keys

public java.util.Set keys()
Description copied from interface: ComponentMap
Get all the component keys.

Specified by:
keys in interface ComponentMap
Returns:
the component keys.