KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gnu > kawa > xslt > TemplateTable


1 package gnu.kawa.xslt;
2 import gnu.mapping.Procedure;
3 import gnu.mapping.Symbol;
4
5 /** Manages the set of xslt templates that have the same 'mode'. */
6
7 public class TemplateTable
8 {
9   /** The "mode" parameter of xsl:template. */
10   Symbol name;
11
12   static final TemplateTable nullModeTable = new TemplateTable(XSLT.nullMode);
13
14   public TemplateTable(Symbol mode)
15   {
16     this.name = mode;
17   }
18
19   static TemplateTable getTemplateTable(Symbol name)
20   {
21     if (name == XSLT.nullMode)
22       return nullModeTable;
23     return null; // FIXME
24
}
25
26   TemplateEntry entries; // For now - later use HashTable.
27

28   public void enter(String JavaDoc pattern, double priority, Procedure procedure)
29   {
30     TemplateEntry entry = new TemplateEntry();
31     entry.procedure = procedure;
32     entry.priority = priority;
33     entry.pattern = pattern;
34     entry.next = entries;
35     entries = entry;
36   }
37
38   public Procedure find (String JavaDoc name)
39   {
40     for (TemplateEntry entry = entries; entry != null; entry = entry.next)
41       {
42     if (entry.pattern.equals(name))
43       return entry.procedure;
44       }
45     return null;
46   }
47 }
48
49 /** Each xsl:template creates a TemplateEntry. */
50
51 class TemplateEntry
52 {
53   Procedure procedure;
54   double priority;
55   String JavaDoc pattern;
56   TemplateEntry next;
57 }
58
Popular Tags