KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > portal > common > context > Context


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.common.context;
11
12 import java.util.Collections JavaDoc;
13 import java.util.Iterator JavaDoc;
14
15 /**
16  * @author <a HREF="mailto:julien@jboss.org">Julien Viet </a>
17  * @version $Revision: 1.1.1.1 $
18  */

19 public interface Context
20 {
21    /** null context */
22    Context NULL_CONTEXT = new AbstractContext()
23    {
24       final Iterator JavaDoc it = Collections.EMPTY_LIST.iterator();
25
26       public Iterator JavaDoc childIterator(String JavaDoc name)
27       {
28          return it;
29       }
30
31       public String JavaDoc get(String JavaDoc key)
32       {
33          return "";
34       }
35
36       public Context put(String JavaDoc key, String JavaDoc value)
37       {
38          return this;
39       }
40
41       public Context put(String JavaDoc key, Integer JavaDoc value)
42       {
43          return this;
44       }
45    };
46
47    /**
48     * get the template data from the context
49     *
50     * @param key
51     * template variable name
52     *
53     * @return template value
54     */

55    public String JavaDoc get(String JavaDoc key);
56
57    /**
58     * add data to be rendered in the template through variable substitution
59     *
60     * @param key
61     * template variable name
62     * @param value
63     * value to render in template
64     *
65     * @return context to place data into
66     */

67    public Context put(String JavaDoc key, String JavaDoc value);
68
69    /**
70     * add data to be rendered in the template through variable substitution
71     *
72     * @param key
73     * template variable name
74     * @param value
75     * value to render in template
76     *
77     * @return context to place data into
78     */

79    public Context put(String JavaDoc key, Integer JavaDoc value);
80
81    /**
82     * get an iterator for the nested/loop data contexts
83     *
84     * @param name
85     * template variable prefix name
86     *
87     * @return iterator for the children
88     */

89    Iterator JavaDoc childIterator(String JavaDoc name);
90 }
Popular Tags