1 52 53 package freemarker.cache; 54 55 import java.net.URL ; 56 57 63 public class ClassTemplateLoader extends URLTemplateLoader 64 { 65 private final Class loaderClass; 66 private final String path; 67 68 75 public ClassTemplateLoader() 76 { 77 this(ClassTemplateLoader.class); 78 } 79 80 92 public ClassTemplateLoader(Class loaderClass) 93 { 94 this(loaderClass, ""); 95 } 96 97 109 public ClassTemplateLoader(Class loaderClass, String path) 110 { 111 if(loaderClass == null) 112 { 113 throw new IllegalArgumentException ("loaderClass == null"); 114 } 115 if(path == null) 116 { 117 throw new IllegalArgumentException ("path == null"); 118 } 119 120 this.loaderClass = loaderClass; 121 this.path = canonicalizePrefix(path); 122 } 123 124 protected URL getURL(String name) 125 { 126 return loaderClass.getResource(path + name); 127 } 128 } | Popular Tags |