KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > portal > format > template > ChildrenStrategy


1 /*****************************************
2  * *
3  * JBoss Portal: The OpenSource Portal *
4  * *
5  * Distributable under LGPL license. *
6  * See terms of license at gnu.org. *
7  * *
8  *****************************************/

9
10 package org.jboss.portal.format.template;
11
12 import java.util.Collections JavaDoc;
13 import java.util.Iterator JavaDoc;
14 import java.util.LinkedList JavaDoc;
15 import java.util.List JavaDoc;
16 import java.util.Map JavaDoc;
17
18 /**
19  * @author <a HREF="mailto:julien@jboss.org">Julien Viet</a>
20  * @version $Revision: 1.2 $
21  */

22 public class ChildrenStrategy
23 {
24
25    public ChildrenStrategy(Map JavaDoc children)
26    {
27       this.children = children;
28    }
29
30    private Map JavaDoc children;
31
32    public void append(String JavaDoc name, Context ctx)
33    {
34       List JavaDoc child = (List JavaDoc)children.get(name);
35       if (child == null)
36       {
37          child = new LinkedList JavaDoc();
38          children.put(name, child);
39       }
40       child.add(ctx);
41    }
42
43    public Iterator JavaDoc childIterator(String JavaDoc name)
44    {
45       List JavaDoc child = (List JavaDoc)children.get(name);
46       return child != null ? child.iterator() : Collections.EMPTY_LIST.iterator();
47    }
48
49 }
50
Popular Tags