Class DelimitingTemplateLoader
- java.lang.Object
-
- edu.cornell.mannlib.vitro.webapp.controller.freemarker.DelimitingTemplateLoader
-
- All Implemented Interfaces:
freemarker.cache.TemplateLoader
public class DelimitingTemplateLoader extends Object implements freemarker.cache.TemplateLoader
Wrap a TemplateLoader, so each time a template is read, delimiters will be inserted at the beginning and end. This makes it easier for a developer can see what lines of HTML come from which templates. TemplateLoader returns a token object when finding a template, and then recognizes that object when it is used as an argument to getLastModified() or getReader(). In order to keep track of the template name, we wrap the token object and the name in a token of our own. Taking the easy way out and reading in the entire template into a string. This limits the template size to less than 2^31 characters (~2 GBytes). That seems adequate.
-
-
Constructor Summary
Constructors Constructor Description DelimitingTemplateLoader(freemarker.cache.TemplateLoader innerLoader)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcloseTemplateSource(Object templateSource)ObjectfindTemplateSource(String name)longgetLastModified(Object templateSource)ReadergetReader(Object templateSource, String encoding)
-
-
-
Method Detail
-
findTemplateSource
public Object findTemplateSource(String name) throws IOException
- Specified by:
findTemplateSourcein interfacefreemarker.cache.TemplateLoader- Throws:
IOException
-
getLastModified
public long getLastModified(Object templateSource)
- Specified by:
getLastModifiedin interfacefreemarker.cache.TemplateLoader
-
getReader
public Reader getReader(Object templateSource, String encoding) throws IOException
- Specified by:
getReaderin interfacefreemarker.cache.TemplateLoader- Throws:
IOException
-
closeTemplateSource
public void closeTemplateSource(Object templateSource) throws IOException
- Specified by:
closeTemplateSourcein interfacefreemarker.cache.TemplateLoader- Throws:
IOException
-
-