KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > webwork > components > template > Template


1 package com.opensymphony.webwork.components.template;
2
3 import java.util.ArrayList JavaDoc;
4 import java.util.List JavaDoc;
5
6 /**
7  * User: plightbo
8  * Date: Aug 10, 2005
9  * Time: 8:06:51 PM
10  */

11 public class Template implements Cloneable JavaDoc {
12     String JavaDoc dir;
13     String JavaDoc theme;
14     String JavaDoc name;
15
16     public Template(String JavaDoc dir, String JavaDoc theme, String JavaDoc name) {
17         this.dir = dir;
18         this.theme = theme;
19         this.name = name;
20     }
21
22     public String JavaDoc getDir() {
23         return dir;
24     }
25
26     public String JavaDoc getTheme() {
27         return theme;
28     }
29
30     public String JavaDoc getName() {
31         return name;
32     }
33
34     public List JavaDoc getPossibleTemplates(TemplateEngine engine) {
35         ArrayList JavaDoc list = new ArrayList JavaDoc(3);
36         Template template = this;
37         String JavaDoc parentTheme;
38         list.add(template);
39         while ((parentTheme = (String JavaDoc) engine.getThemeProps(template).get("parent")) != null) {
40             try {
41                 template = (Template) template.clone();
42                 template.theme = parentTheme;
43                 list.add(template);
44             } catch (CloneNotSupportedException JavaDoc e) {
45             }
46         }
47
48         return list;
49     }
50
51     public String JavaDoc toString() {
52         return "/" + dir + "/" + theme + "/" + name;
53     }
54
55     protected Object JavaDoc clone() throws CloneNotSupportedException JavaDoc {
56         return super.clone();
57     }
58 }
59
Popular Tags