com.opencms.template
Interface I_CmsTemplate

All Known Subinterfaces:
I_CmsDumpTemplate, I_CmsJavascriptTemplate, I_CmsXmlTemplate
All Known Implementing Classes:
A_CmsTemplate, CmsDumpTemplate, CmsJavascriptTemplate, CmsNewExplorerFileList, CmsXmlTemplate

public interface I_CmsTemplate

Common interface for OpenCms template classes. Classes and interfaces for each customized template type have to be implemtented.

Version:
$Revision: 1.16 $ $Date: 2003/01/20 23:59:21 $
Author:
Alexander Lucas

Method Summary
 CmsCacheDirectives collectCacheDirectives(CmsObject cms, String templateFile, String elementName, Hashtable parameters, String templateSelector)
          Collect caching informations from the current template class.
 A_CmsElement createElement(CmsObject cms, String templateFile, Hashtable parameters)
          Create a new element for the element cache consisting of the current template class and the given template file.
 byte[] getContent(CmsObject cms, String templateFile, String elementName, Hashtable parameters)
          Gets the content of a given template file with the given parameters.
 byte[] getContent(CmsObject cms, String templateFile, String elementName, Hashtable parameters, String templateSelector)
          Gets the content of a defined section in a given template file with the given parameters.
 Object getKey(CmsObject cms, String templateFile, Hashtable parameters, String templateSelector)
          Gets the key that should be used to cache the results of this template class.
 boolean isCacheable(CmsObject cms, String templateFile, String elementName, Hashtable parameters, String templateSelector)
          Indicates if the results of this class are cacheable.
 boolean isExportable(CmsObject cms, String templateFile, String elementName, Hashtable parameters, String templateSelector)
          Indicates if the results of this class are "static" and may be exported.
 boolean isProxyPrivateCacheable(CmsObject cms, String templateFile, String elementName, Hashtable parameters, String templateSelector)
          Indicates if the results of this class may be cached by public proxy caches.
 boolean isProxyPublicCacheable(CmsObject cms, String templateFile, String elementName, Hashtable parameters, String templateSelector)
          Indicates if the results of this class may be cached by public proxy caches.
 boolean isStreamable(CmsObject cms, String templateFile, String elementName, Hashtable parameters, String templateSelector)
          Indicates if the current template class is able to stream it's results directly to the response oputput stream.
 boolean isTemplateCacheSet()
          Tests, if the template cache is setted.
 void setTemplateCache(I_CmsTemplateCache c)
          Set the instance of template cache that should be used to store cacheable results of the subtemplates.
 boolean shouldReload(CmsObject cms, String templateFile, String elementName, Hashtable parameters, String templateSelector)
          Indicates if a previous cached result should be reloaded.
 

Method Detail

getContent

public byte[] getContent(CmsObject cms,
                         String templateFile,
                         String elementName,
                         Hashtable parameters)
                  throws CmsException
Gets the content of a given template file with the given parameters.

Parameters are stored in a hashtable and can derive from

Paramter names must be in "elementName.parameterName" format.

Parameters:
cms - CmsObject Object for accessing system resources
templateFile - Filename of the template file
elementName - Element name of this template in our parent template
parameters - Hashtable with all template class parameters.
Returns:
Content of the template and all subtemplates.
Throws:
CmsException

getContent

public byte[] getContent(CmsObject cms,
                         String templateFile,
                         String elementName,
                         Hashtable parameters,
                         String templateSelector)
                  throws CmsException
Gets the content of a defined section in a given template file with the given parameters.

Parameters:
cms - CmsObject Object for accessing system resources.
templateFile - Filename of the template file.
elementName - Element name of this template in our parent template.
parameters - Hashtable with all template class parameters.
templateSelector - section that should be processed.
Returns:
Content of the template and all subtemplates.
Throws:
CmsException
See Also:
getContent(CmsObject, String, String, Hashtable, String)

getKey

public Object getKey(CmsObject cms,
                     String templateFile,
                     Hashtable parameters,
                     String templateSelector)
Gets the key that should be used to cache the results of this template class. For simple template classes, e.g. classes only dumping file contents and not using parameters, the name of the template file may be adequate. Other classes have to return a more complex key.

Parameters:
cms - CmsObject Object for accessing system resources
templateFile - Filename of the template file
parameters - Hashtable with all template class parameters.
templateSelector - template section that should be processed.
Returns:
key that can be used for caching

isCacheable

public boolean isCacheable(CmsObject cms,
                           String templateFile,
                           String elementName,
                           Hashtable parameters,
                           String templateSelector)
Indicates if the results of this class are cacheable.

Complex classes that are able top include other subtemplates have to check the cacheability of their subclasses here!

Parameters:
cms - CmsObject Object for accessing system resources
templateFile - Filename of the template file
elementName - Element name of this template in our parent template.
parameters - Hashtable with all template class parameters.
templateSelector - template section that should be processed.
Returns:
true if cacheable, false otherwise.

isProxyPrivateCacheable

public boolean isProxyPrivateCacheable(CmsObject cms,
                                       String templateFile,
                                       String elementName,
                                       Hashtable parameters,
                                       String templateSelector)
Indicates if the results of this class may be cached by public proxy caches.

Complex classes that are able top include other subtemplates have to check the cacheability of their subclasses here!

Parameters:
cms - CmsObject Object for accessing system resources
templateFile - Filename of the template file
elementName - Element name of this template in our parent template.
parameters - Hashtable with all template class parameters.
templateSelector - template section that should be processed.
Returns:
true if cacheable, false otherwise.

isProxyPublicCacheable

public boolean isProxyPublicCacheable(CmsObject cms,
                                      String templateFile,
                                      String elementName,
                                      Hashtable parameters,
                                      String templateSelector)
Indicates if the results of this class may be cached by public proxy caches.

Complex classes that are able top include other subtemplates have to check the cacheability of their subclasses here!

Parameters:
cms - CmsObject Object for accessing system resources
templateFile - Filename of the template file
elementName - Element name of this template in our parent template.
parameters - Hashtable with all template class parameters.
templateSelector - template section that should be processed.
Returns:
true if cacheable, false otherwise.

isExportable

public boolean isExportable(CmsObject cms,
                            String templateFile,
                            String elementName,
                            Hashtable parameters,
                            String templateSelector)
Indicates if the results of this class are "static" and may be exported.

Default conditions are:

Complex classes that are able top include other subtemplates have to check the cacheability of their subclasses here!

Parameters:
cms - CmsObject Object for accessing system resources
templateFile - Filename of the template file
elementName - Element name of this template in our parent template.
parameters - Hashtable with all template class parameters.
templateSelector - template section that should be processed.
Returns:
true if cacheable, false otherwise.

isStreamable

public boolean isStreamable(CmsObject cms,
                            String templateFile,
                            String elementName,
                            Hashtable parameters,
                            String templateSelector)
Indicates if the current template class is able to stream it's results directly to the response oputput stream.

Classes must not set this feature, if they might throw special exception that cause HTTP errors (e.g. 404/Not Found), or if they might send HTTP redirects.

If a class sets this feature, it has to check the isStreaming() property of the RequestContext. If this is set to true the results must be streamed directly to the output stream. If it is false the results must not be streamed.

Complex classes that are able top include other subtemplates have to check the streaming ability of their subclasses here!

Parameters:
cms - CmsObject Object for accessing system resources
templateFile - Filename of the template file
elementName - Element name of this template in our parent template.
parameters - Hashtable with all template class parameters.
templateSelector - template section that should be processed.
Returns:
true if this class may stream it's results, false otherwise.

collectCacheDirectives

public CmsCacheDirectives collectCacheDirectives(CmsObject cms,
                                                 String templateFile,
                                                 String elementName,
                                                 Hashtable parameters,
                                                 String templateSelector)
Collect caching informations from the current template class.

Complex classes that are able to include other subtemplates have to check the streaming ability of their subclasses here!

Parameters:
cms - CmsObject Object for accessing system resources
templateFile - Filename of the template file
elementName - Element name of this template in our parent template.
parameters - Hashtable with all template class parameters.
templateSelector - template section that should be processed.
Returns:
true if this class may stream it's results, false otherwise.

isTemplateCacheSet

public boolean isTemplateCacheSet()
Tests, if the template cache is setted.

Returns:
true if setted, false otherwise.

setTemplateCache

public void setTemplateCache(I_CmsTemplateCache c)
Set the instance of template cache that should be used to store cacheable results of the subtemplates. If the template cache is not set, caching will be disabled.

Parameters:
c - Template cache to be used.

shouldReload

public boolean shouldReload(CmsObject cms,
                            String templateFile,
                            String elementName,
                            Hashtable parameters,
                            String templateSelector)
Indicates if a previous cached result should be reloaded.

Parameters:
cms - CmsObject Object for accessing system resources
templateFile - Filename of the template file
elementName - Element name of this template in our parent template.
parameters - Hashtable with all template class parameters.
templateSelector - template section that should be processed.
Returns:
true if reload is neccesary, false otherwise.

createElement

public A_CmsElement createElement(CmsObject cms,
                                  String templateFile,
                                  Hashtable parameters)
Create a new element for the element cache consisting of the current template class and the given template file.

Complex template classes that are able to include other (sub-)templates must generate a collection of element definitions for their possible subtemplates. This collection is part of the new element.

Parameters:
cms - CmsObject for accessing system resources.
templateFile - Name of the template file for the new element
parameters - All parameters of the current request
Returns:
New element for the element cache