org.peaseplate
Interface TemplateEngine

All Known Subinterfaces:
IPeasePlateEngine
All Known Implementing Classes:
PeasePlateEngine

public interface TemplateEngine

This class represents the central engine of the Pease Plate engine.

Usually just create exactly one instance of this class for all your rendering duties. It stores all global and reusable settings for template rendering and is thread safe. It contains a cache that stores compiled templates.

Author:
Manfred HANTSCHEL

Method Summary
 void addClassLoader(java.lang.ClassLoader... classLoaders)
          Adds the specified class loaders to the facotry.
 Template compile(char[] source)
          Compiles the template defined by the source.
 Template compile(java.lang.String source)
          Compiles the template defined by the source.
 Template compile(TemplateLocator locator)
          Compiles the template defined by the specified locator.
 CacheService getCacheService()
          Returns the cache service used to cache templates and messages
 java.util.Collection<java.lang.ClassLoader> getClassLoaders()
          Returns all the class loaders in an unmodifiable collection.
 ConversionService getConversionService()
          Returns the conversion service used to convert objects from one type to another
 java.lang.String getDefaultEncoding()
          Returns the default encoding used when no encoding is specified somewhere where needed
 LineSeparator getDefaultLineSeparator()
          Returns the default line separator
 java.util.Locale getDefaultLocale()
          Returns the default locale used when no locale is specified somewhere where needed
 DesignatorService getDesignatorService()
          Returns the designator service used to resolve and handle designators
 MacroService getMacroService()
          Returns the macro service used to resolve and handle predefined macros
 ResolverService getResolverService()
          Returns the resolver service used to resolve templates and messages
 TransformerService getTransformerService()
          Returns the transformer service used to resolve and handle transformers
 void render(java.io.Writer writer, java.lang.Object workingObject, ResourceKey key)
          Renders the template specified by the descriptor

The workingObject is just any object or bean, that contains the data that should be integrated in the template.
 void render(java.io.Writer writer, java.lang.Object workingObject, java.lang.String name)
          Renders the template with the specified name to the specified writer.
 void render(java.io.Writer writer, java.lang.Object workingObject, java.lang.String name, java.util.Locale locale)
          Renders the template with the specified name to the specified writer.
 void render(java.io.Writer writer, java.lang.Object workingObject, java.lang.String name, java.util.Locale locale, java.lang.String encoding)
          Renders the template with the specified name to the specified writer.
 void render(java.io.Writer writer, java.lang.Object workingObject, java.lang.String name, java.lang.String encoding)
          Renders the template with the specified name to the specified writer.
 void setDefaultEncoding(java.lang.String defaultEncoding)
          Sets the default encoding used when no encoding is specified somewhere where needed
 void setDefaultLineSeparator(LineSeparator defaultLineSeparator)
          Sets the default line separator
 void setDefaultLocale(java.util.Locale defaultLocale)
          Sets the default locale used when no locale is specified somewhere where needed
 

Method Detail

addClassLoader

void addClassLoader(java.lang.ClassLoader... classLoaders)
Adds the specified class loaders to the facotry. The class loader is used for multiple purposes, like initializing the services. The there is a new class loader added, the services will get initialized with it.

Parameters:
classLoaders - the class loaders

getClassLoaders

java.util.Collection<java.lang.ClassLoader> getClassLoaders()
Returns all the class loaders in an unmodifiable collection.

Returns:
the classLoaders

getCacheService

CacheService getCacheService()
Returns the cache service used to cache templates and messages

Returns:
the cache service

getResolverService

ResolverService getResolverService()
Returns the resolver service used to resolve templates and messages

Returns:
the resolver service

getDesignatorService

DesignatorService getDesignatorService()
Returns the designator service used to resolve and handle designators

Returns:
the designator service

getTransformerService

TransformerService getTransformerService()
Returns the transformer service used to resolve and handle transformers

Returns:
the transformer service

getMacroService

MacroService getMacroService()
Returns the macro service used to resolve and handle predefined macros

Returns:
the macro service

getConversionService

ConversionService getConversionService()
Returns the conversion service used to convert objects from one type to another

Returns:
the conversion service

getDefaultLocale

java.util.Locale getDefaultLocale()
Returns the default locale used when no locale is specified somewhere where needed

Returns:
teh default locale

setDefaultLocale

void setDefaultLocale(java.util.Locale defaultLocale)
Sets the default locale used when no locale is specified somewhere where needed

Parameters:
defaultLocale - the default locale

getDefaultEncoding

java.lang.String getDefaultEncoding()
Returns the default encoding used when no encoding is specified somewhere where needed

Returns:
the default encoding

setDefaultEncoding

void setDefaultEncoding(java.lang.String defaultEncoding)
Sets the default encoding used when no encoding is specified somewhere where needed

Parameters:
defaultEncoding - the default encoding

getDefaultLineSeparator

LineSeparator getDefaultLineSeparator()
Returns the default line separator

Returns:
the default line separator

setDefaultLineSeparator

void setDefaultLineSeparator(LineSeparator defaultLineSeparator)
Sets the default line separator

Parameters:
defaultLineSeparator - the default line separator

compile

Template compile(TemplateLocator locator)
                 throws TemplateException
Compiles the template defined by the specified locator. This is the base method for compiling templates.

Parameters:
locator - the locator
Returns:
the compiled template
Throws:
TemplateException - on occasion

compile

Template compile(java.lang.String source)
                 throws TemplateException
Compiles the template defined by the source. Makes use of the InMemoryTemplateLocator, which stores the source in memory.

Parameters:
source - the source
Returns:
the compiled template
Throws:
TemplateException

compile

Template compile(char[] source)
                 throws TemplateException
Compiles the template defined by the source. Makes use of the InMemoryTemplateLocator, which stores the source in memory.

Parameters:
source - the source
Returns:
the compiled template
Throws:
TemplateException

render

void render(java.io.Writer writer,
            java.lang.Object workingObject,
            java.lang.String name)
            throws TemplateException,
                   java.io.IOException
Renders the template with the specified name to the specified writer.

The workingObject is just any object or bean, that contains the data that should be integrated in the template.

The name of the template is usually some path on the file system or the resources but you can enhance this by implementing an own Resolver.

Parameters:
writer - the writer
workingObject - the working object
name - the name of the template
Throws:
TemplateException - if anything goes wrong
java.io.IOException - if it cannot write to the writer

render

void render(java.io.Writer writer,
            java.lang.Object workingObject,
            java.lang.String name,
            java.util.Locale locale)
            throws TemplateException,
                   java.io.IOException
Renders the template with the specified name to the specified writer.

The workingObject is just any object or bean, that contains the data that should be integrated in the template.

The name of the template is usually some path on the file system or the resources but you can enhance this by implementing an own Resolver.

Parameters:
writer - the writer
workingObject - the working object
name - the name of the template
locale - the locale; uses the default locale if null
Throws:
TemplateException - if anything goes wrong
java.io.IOException - if it cannot write to the writer

render

void render(java.io.Writer writer,
            java.lang.Object workingObject,
            java.lang.String name,
            java.lang.String encoding)
            throws TemplateException,
                   java.io.IOException
Renders the template with the specified name to the specified writer.

The workingObject is just any object or bean, that contains the data that should be integrated in the template.

The name of the template is usually some path on the file system or the resources but you can enhance this by implementing an own Resolver.

Parameters:
writer - the writer
workingObject - the working object
name - the name of the template
encoding - the encoding; uses the default encoding if null
Throws:
TemplateException - if anything goes wrong
java.io.IOException - if it cannot write to the writer

render

void render(java.io.Writer writer,
            java.lang.Object workingObject,
            java.lang.String name,
            java.util.Locale locale,
            java.lang.String encoding)
            throws TemplateException,
                   java.io.IOException
Renders the template with the specified name to the specified writer.

The workingObject is just any object or bean, that contains the data that should be integrated in the template.

The name of the template is usually some path on the file system or the resources but you can enhance this by implementing an own Resolver.

Parameters:
writer - the writer
workingObject - the working object
name - the name of the template
locale - the locale; uses the default locale if null
encoding - the encoding; uses the default encoding if null
Throws:
TemplateException - if anything goes wrong
java.io.IOException - if it cannot write to the writer

render

void render(java.io.Writer writer,
            java.lang.Object workingObject,
            ResourceKey key)
            throws TemplateException,
                   java.io.IOException
Renders the template specified by the descriptor

The workingObject is just any object or bean, that contains the data that should be integrated in the template.

The name of the template is usually some path on the file system or the resources but you can enhance this by implementing an own Resolver.

Parameters:
writer - the writer
workingObject - the working object
key - the key
Throws:
TemplateException - if anything goes wrong
java.io.IOException - if it cannot write to the writer


Copyright © 2008. All Rights Reserved.