KickJava   Java API By Example, From Geeks To Geeks.

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

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

50    public String JavaDoc get(String JavaDoc key);
51
52    /**
53     * add data to be rendered in the template through variable substitution
54     *
55     * @param key template variable name
56     * @param value value to render in template
57     *
58     * @return context to place data into
59     */

60    public Context put(String JavaDoc key, String JavaDoc value);
61
62    /**
63     * get an iterator for the nested/loop data contexts
64     *
65     * @param name template variable prefix name
66     *
67     * @return iterator for the children
68     */

69    Iterator JavaDoc childIterator(String JavaDoc name);
70 }
71
Popular Tags