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