Class composite.Composite


public class Composite
extends composite.AComponent
A concrete component that represents a collection of abstract components. The client can use a Composite equivalently to a Leaf. Any calls to the operation() method are simply dispatched sequentially to the AComponent children.


Variable Index

 o children
A collection of abstract components

Method Index

 o addChild (AComponent)
Adds the supplied component as a child
 o operation ()
A concrete operation that can be used by a Client
 o removeChild (AComponent)
Removes a AComponent child given a reference to it

Variables

 o children
private AComponent[] children = new Component[10]
A collection of abstract components. Shown here as an array, but the the system is independent of the collection's implementation.

Methods

 o operation
public void operation()
A concrete operation that can be used by a Client. This method simply dipatches the operation request sequentially to all the AComponent children.

 o removeChild
public AComponent removeChild(AComponent child)
Removes a AComponent child given a reference to it. Returns the reference the child if it was found.

Parameters:
child -
 o addChild
public void addChild(AComponent child)
Adds the supplied component as a child.

Parameters:
child -