org.abstracthorizon.danube.freemarker
Class FreeMarkerViewAdapter.LocalTemplateLoader

java.lang.Object
  extended by org.abstracthorizon.danube.freemarker.FreeMarkerViewAdapter.LocalTemplateLoader
All Implemented Interfaces:
TemplateLoader
Enclosing class:
FreeMarkerViewAdapter

public class FreeMarkerViewAdapter.LocalTemplateLoader
extends Object
implements TemplateLoader

Local template loader that uses templates path or templates URL (which ever is supplied). Templates path has advantage against URL.


Constructor Summary
FreeMarkerViewAdapter.LocalTemplateLoader()
          Constructor
 
Method Summary
 void closeTemplateSource(Object tmp)
          This method does nothing
 Object findTemplateSource(String path)
          This method returns a file or an URL if file is not available and URL's input stream can be accessed (it tries to read ONE byte of it).
 long getLastModified(Object tmp)
          This method returns file's last modified attribute if file is supplied.
 Reader getReader(Object tmp, String encoding)
          Returns an reader from file or URL or null if that fails
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FreeMarkerViewAdapter.LocalTemplateLoader

public FreeMarkerViewAdapter.LocalTemplateLoader()
Constructor

Method Detail

closeTemplateSource

public void closeTemplateSource(Object tmp)
                         throws IOException
This method does nothing

Specified by:
closeTemplateSource in interface TemplateLoader
Parameters:
tmp - template resource
Throws:
IOException

findTemplateSource

public Object findTemplateSource(String path)
                          throws IOException
This method returns a file or an URL if file is not available and URL's input stream can be accessed (it tries to read ONE byte of it).

Specified by:
findTemplateSource in interface TemplateLoader
Parameters:
path - path to resource
Returns:
file, URL or null
Throws:
IOException

getLastModified

public long getLastModified(Object tmp)
This method returns file's last modified attribute if file is supplied. If not it tries to invoke last modified on an URL. If that fails too then it returns -1

Specified by:
getLastModified in interface TemplateLoader
Parameters:
tmp - resource which has to be a file or URL.
Returns:
file's or url's last modified or -1

getReader

public Reader getReader(Object tmp,
                        String encoding)
                 throws IOException
Returns an reader from file or URL or null if that fails

Specified by:
getReader in interface TemplateLoader
Parameters:
tmp - file or URL
encoding - encoding
Returns:
file reader or input stream reader of URL's input stream or null
Throws:
IOException


Copyright © 2005-2009 Abstract Horizon. All Rights Reserved.