KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jfun > yan > containers > TransformingContainer


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 8, 2005
10  *
11  * Author Ben Yu
12  * ZBS
13  */

14 package jfun.yan.containers;
15 import jfun.yan.Component;
16 import jfun.yan.Registrar;
17
18 /**
19  * A Container that transforms a Component using a ComponentTransformer
20  * object before the component is registered into the container.
21  * <p>
22  * Codehaus.org.
23  *
24  * @author Ben Yu
25  *
26  */

27 public class TransformingContainer extends SimpleContainer {
28   private final ComponentTransformer ct;
29   /**
30    * Create a TransformingContainer object.
31    * @param target the registrar that stores the components.
32    * @param ct the transformer.
33    */

34   public TransformingContainer(Registrar target,
35       ComponentTransformer ct) {
36     super(target);
37     this.ct = ct;
38   }
39   public void registerComponent(Object JavaDoc key, Component cc){
40     super.registerComponent(key, ct.transform(key, cc));
41   }
42   public void registerComponent(Component cc){
43     super.registerComponent(ct.transform(cc));
44   }
45 }
46
Popular Tags