Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.opencms.template
Interface I_CmsTemplate  view I_CmsTemplate download I_CmsTemplate.java

All Known Subinterfaces:
I_CmsDumpTemplate, I_CmsJavascriptTemplate, I_CmsXmlTemplate
All Known Implementing Classes:
A_CmsTemplate, CmsDumpTemplate, CmsJavascriptTemplate, 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 $

Method Summary
 CmsCacheDirectives collectCacheDirectives(com.opencms.file.CmsObject cms, java.lang.String templateFile, java.lang.String elementName, java.util.Hashtable parameters, java.lang.String templateSelector)
          Collect caching informations from the current template class.
 com.opencms.template.cache.A_CmsElement createElement(com.opencms.file.CmsObject cms, java.lang.String templateFile, java.util.Hashtable parameters)
          Create a new element for the element cache consisting of the current template class and the given template file.
 byte[] getContent(com.opencms.file.CmsObject cms, java.lang.String templateFile, java.lang.String elementName, java.util.Hashtable parameters)
          Gets the content of a given template file with the given parameters.
 byte[] getContent(com.opencms.file.CmsObject cms, java.lang.String templateFile, java.lang.String elementName, java.util.Hashtable parameters, java.lang.String templateSelector)
          Gets the content of a defined section in a given template file with the given parameters.
 java.lang.Object getKey(com.opencms.file.CmsObject cms, java.lang.String templateFile, java.util.Hashtable parameters, java.lang.String templateSelector)
          Gets the key that should be used to cache the results of this template class.
 boolean isCacheable(com.opencms.file.CmsObject cms, java.lang.String templateFile, java.lang.String elementName, java.util.Hashtable parameters, java.lang.String templateSelector)
          Indicates if the results of this class are cacheable.
 boolean isExportable(com.opencms.file.CmsObject cms, java.lang.String templateFile, java.lang.String elementName, java.util.Hashtable parameters, java.lang.String templateSelector)
          Indicates if the results of this class are "static" and may be exported.
 boolean isProxyPrivateCacheable(com.opencms.file.CmsObject cms, java.lang.String templateFile, java.lang.String elementName, java.util.Hashtable parameters, java.lang.String templateSelector)
          Indicates if the results of this class may be cached by public proxy caches.
 boolean isProxyPublicCacheable(com.opencms.file.CmsObject cms, java.lang.String templateFile, java.lang.String elementName, java.util.Hashtable parameters, java.lang.String templateSelector)
          Indicates if the results of this class may be cached by public proxy caches.
 boolean isStreamable(com.opencms.file.CmsObject cms, java.lang.String templateFile, java.lang.String elementName, java.util.Hashtable parameters, java.lang.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(com.opencms.launcher.I_CmsTemplateCache c)
          Set the instance of template cache that should be used to store cacheable results of the subtemplates.
 boolean shouldReload(com.opencms.file.CmsObject cms, java.lang.String templateFile, java.lang.String elementName, java.util.Hashtable parameters, java.lang.String templateSelector)
          Indicates if a previous cached result should be reloaded.
 

Method Detail

getContent

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

Parameters are stored in a hashtable and can derive from

  • Template file of the parent template
  • Body file clicked by the user
  • URL parameters
Paramter names must be in "elementName.parameterName" format.


getContent

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


getKey

public java.lang.Object getKey(com.opencms.file.CmsObject cms,
                               java.lang.String templateFile,
                               java.util.Hashtable parameters,
                               java.lang.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.


isCacheable

public boolean isCacheable(com.opencms.file.CmsObject cms,
                           java.lang.String templateFile,
                           java.lang.String elementName,
                           java.util.Hashtable parameters,
                           java.lang.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!


isProxyPrivateCacheable

public boolean isProxyPrivateCacheable(com.opencms.file.CmsObject cms,
                                       java.lang.String templateFile,
                                       java.lang.String elementName,
                                       java.util.Hashtable parameters,
                                       java.lang.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!


isProxyPublicCacheable

public boolean isProxyPublicCacheable(com.opencms.file.CmsObject cms,
                                      java.lang.String templateFile,
                                      java.lang.String elementName,
                                      java.util.Hashtable parameters,
                                      java.lang.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!


isExportable

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

Default conditions are:

  • Resource may be cached by public proxies
  • There are no parameters in the URL
  • The resource's internal flag must not be set

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


isStreamable

public boolean isStreamable(com.opencms.file.CmsObject cms,
                            java.lang.String templateFile,
                            java.lang.String elementName,
                            java.util.Hashtable parameters,
                            java.lang.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!


collectCacheDirectives

public CmsCacheDirectives collectCacheDirectives(com.opencms.file.CmsObject cms,
                                                 java.lang.String templateFile,
                                                 java.lang.String elementName,
                                                 java.util.Hashtable parameters,
                                                 java.lang.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!


isTemplateCacheSet

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


setTemplateCache

public void setTemplateCache(com.opencms.launcher.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.


shouldReload

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


createElement

public com.opencms.template.cache.A_CmsElement createElement(com.opencms.file.CmsObject cms,
                                                             java.lang.String templateFile,
                                                             java.util.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.