com.arsdigita.cms
Class DefaultTemplateManager

java.lang.Object
  extended bycom.arsdigita.cms.DefaultTemplateManager
All Implemented Interfaces:
TemplateManager

public class DefaultTemplateManager
extends Object
implements TemplateManager

A default implementation of template manager.

Version:
$Revision: #11 $ $DateTime: 2004/04/07 16:07:11 $
Author:
Karl Goldstein (karlg@arsdigita.com)

Field Summary
static String versionId
           
 
Fields inherited from interface com.arsdigita.cms.TemplateManager
PUBLIC_CONTEXT
 
Constructor Summary
DefaultTemplateManager()
          Construct a new template manager
 
Method Summary
 void addTemplate(ContentItem item, Template template, String context)
          Assign a template to the item in the given context.
 void addTemplate(ContentItem item, Template template, String context, com.arsdigita.mimetypes.MimeType mimeType)
          Assign a template to the item in the given context.
 void addTemplate(ContentSection section, ContentType type, Template template, String context)
          Add a template to the given content type for the given content section.
 void addTemplate(ContentSection section, ContentType type, Template template, String context, boolean isDefault)
          Add a template to the given content type for the given content section.
 com.arsdigita.cms.ItemTemplateCollection getContextsWithTypes(ContentItem item)
          Retrieve all use context/mime type combinations along with possibly null template for the item in that pair.
 Template getDefaultTemplate(ContentSection section, ContentType type, String context)
          Get the default template for the given section, type and use context
 Template getDefaultTemplate(ContentSection section, ContentType type, String context, com.arsdigita.mimetypes.MimeType mimeType)
          Get the default template for the given section, type and use context
 Template getTemplate(ContentItem item, String context)
          Retrieve a template for the item in the given use context.
 TemplateCollection getTemplates(ContentItem item)
          Retrieve all templates for the content item
 TemplateCollection getTemplates(ContentSection section, ContentType type)
          Get all the templates within the given section and type
 TemplateCollection getTemplates(ContentSection section, ContentType type, String context)
          Get all the templates within the given section, type and context
 TemplateCollection getUseContexts(ContentItem item)
          Retrieve a collection of all use contexts for the item, along with the templates assigned to each use context (if any).
 void removeTemplate(ContentItem item, Template template, String context)
          Unassign a template from the item in the given context.
 void removeTemplate(ContentSection section, ContentType type, Template template, String context)
          Remove the specified template from the content type in the given context.
 void setDefaultTemplate(ContentSection section, ContentType type, Template template, String useContext)
          Designate the given template as the default template within its use context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

versionId

public static final String versionId
See Also:
Constant Field Values
Constructor Detail

DefaultTemplateManager

public DefaultTemplateManager()
Construct a new template manager

Method Detail

addTemplate

public void addTemplate(ContentItem item,
                        Template template,
                        String context,
                        com.arsdigita.mimetypes.MimeType mimeType)
Assign a template to the item in the given context. Overrides any previous template assignment.

Parameters:
item - the content item
template - the template to be assigned
context - the use context for the template, such as "public" or "abridged".

addTemplate

public void addTemplate(ContentItem item,
                        Template template,
                        String context)
Description copied from interface: TemplateManager
Assign a template to the item in the given context. Overrides any previous template assignment.

Specified by:
addTemplate in interface TemplateManager
Parameters:
item - the content item
template - the template to be assigned
context - the use context for the template, such as "public" or "abridged".

removeTemplate

public void removeTemplate(ContentItem item,
                           Template template,
                           String context)
Unassign a template from the item in the given context. Do nothing if the template is not assigned to the item.

Specified by:
removeTemplate in interface TemplateManager
Parameters:
item - the content item
template - the template to be unassigned
context - the use context for the template, such as "public" or "abridged".

addTemplate

public void addTemplate(ContentSection section,
                        ContentType type,
                        Template template,
                        String context,
                        boolean isDefault)
Add a template to the given content type for the given content section. The template could be used to render any item of the content type

Specified by:
addTemplate in interface TemplateManager
Parameters:
section - the content section to which the template will belong
type - the content type to which the template will belong
template - the template to be added
context - the use context for the template, such as "public" or "abridged".
isDefault - if true, new content items of the given type will use this template by default when they are rendered within the specified use context

setDefaultTemplate

public void setDefaultTemplate(ContentSection section,
                               ContentType type,
                               Template template,
                               String useContext)
Designate the given template as the default template within its use context. new content items of the given type will use this template by default when they are rendered within the use context. Note that addTemplate(com.arsdigita.cms.ContentItem, com.arsdigita.cms.Template, java.lang.String, com.arsdigita.mimetypes.MimeType) must first be called to actually add the template to.

Specified by:
setDefaultTemplate in interface TemplateManager
Parameters:
section - the content section where the template resides
type - the content type to which the template belongs
template - the template which will be made default
useContext - the use context in which the template will be made default

addTemplate

public void addTemplate(ContentSection section,
                        ContentType type,
                        Template template,
                        String context)
Add a template to the given content type for the given content section. The template could be used to render any item of the content type. If the given context for the section contains no templates, the new template will be made the default.

Specified by:
addTemplate in interface TemplateManager
Parameters:
section - the content section to which the template will belong
type - the content type to which the template will belong
template - the template to be added
context - the use context for the template, such as "public" or "abridged".

removeTemplate

public void removeTemplate(ContentSection section,
                           ContentType type,
                           Template template,
                           String context)
Remove the specified template from the content type in the given context. Do nothing if no such template is associated.

Specified by:
removeTemplate in interface TemplateManager
Parameters:
section - the content section to which the template belongs
type - the content type to which the template belongs
template - the template to be removed
context - the use context for the template, such as "public" or "abridged".

getTemplate

public Template getTemplate(ContentItem item,
                            String context)
Retrieve a template for the item in the given use context.

Specified by:
getTemplate in interface TemplateManager
Parameters:
item - the content item
context - the use context for the template, such as "public" or "abridged".
Returns:
the template assigned to the item in the given context, or null if no such template is assigned

getTemplates

public TemplateCollection getTemplates(ContentItem item)
Retrieve all templates for the content item

Specified by:
getTemplates in interface TemplateManager
Parameters:
item - the content item
Returns:
a TemplateCollection of all the templates assigned to the item
See Also:
TemplateManager.getUseContexts(com.arsdigita.cms.ContentItem)

getUseContexts

public TemplateCollection getUseContexts(ContentItem item)
Retrieve a collection of all use contexts for the item, along with the templates assigned to each use context (if any). Unlike getTemplates(ContentItem), the collection returned by this method will include all use contexts for an item, even those use contexts to which no template is yet assigned.

Specified by:
getUseContexts in interface TemplateManager
Parameters:
item - the content item
Returns:
a TemplateCollection of all the templates assigned to the item

getContextsWithTypes

public com.arsdigita.cms.ItemTemplateCollection getContextsWithTypes(ContentItem item)
Retrieve all use context/mime type combinations along with possibly null template for the item in that pair. This returns one row for each use context/mime type pair. So, you could get 4 rows if there is public/jsp, public/xsl, alternate/jsp, and alternate/xsl. This is because there can be one template per context/mime-type pair

Specified by:
getContextsWithTypes in interface TemplateManager

getDefaultTemplate

public Template getDefaultTemplate(ContentSection section,
                                   ContentType type,
                                   String context)
Get the default template for the given section, type and use context

Specified by:
getDefaultTemplate in interface TemplateManager
Parameters:
section - the content section to which the template belongs
type - the content type to which the template belongs
context - the use context for the template, such as "public" or "abridged".
Returns:
the default template for the given section, type and context, or null if no such template exists

getDefaultTemplate

public Template getDefaultTemplate(ContentSection section,
                                   ContentType type,
                                   String context,
                                   com.arsdigita.mimetypes.MimeType mimeType)
Get the default template for the given section, type and use context

Specified by:
getDefaultTemplate in interface TemplateManager
Parameters:
section - the content section to which the template belongs
type - the content type to which the template belongs
context - the use context for the template, such as "public" or "abridged".
mimeType - The mime type of the template that is desired.
Returns:
the default template for the given section, type and context, or null if no such template exists

getTemplates

public TemplateCollection getTemplates(ContentSection section,
                                       ContentType type)
Get all the templates within the given section and type

Specified by:
getTemplates in interface TemplateManager
Parameters:
section - the content section
type - the content type
Returns:
a collection of templates for the given section, type and context; an empty collection if there are no such templates

getTemplates

public TemplateCollection getTemplates(ContentSection section,
                                       ContentType type,
                                       String context)
Get all the templates within the given section, type and context

Specified by:
getTemplates in interface TemplateManager
Parameters:
section - the content section
type - the content type
context - the use context
Returns:
a collection of templates for the given section, type and context; an empty collection if there are no such templates


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 21 2004:2352 UTC