org.melati.template
Class ClassNameTempletLoader

java.lang.Object
  extended by org.melati.template.ClassNameTempletLoader
All Implemented Interfaces:
TempletLoader

public final class ClassNameTempletLoader
extends java.lang.Object
implements TempletLoader

Load a template to render an object based upon the object's class.


Method Summary
protected static java.lang.String classpathTempletPath(java.lang.Class clazz, TemplateEngine templateEngine)
           
static ClassNameTempletLoader getInstance()
           
 Template templet(TemplateEngine templateEngine, MarkupLanguage markupLanguage, java.lang.Class clazz)
          Get a templet for a class.
 Template templet(TemplateEngine templateEngine, MarkupLanguage markupLanguage, FieldAttributes attributes)
          Get a templet either from the FieldAttributes or the class name.
 Template templet(TemplateEngine templateEngine, MarkupLanguage markupLanguage, java.lang.String name)
          Get a templet by its name, looking only in the templets directory.
 Template templet(TemplateEngine templateEngine, MarkupLanguage markupLanguage, java.lang.String purpose, java.lang.Class clazz)
          Get a templet based upon class name and optional purpose, looking in the templets directory and also the classpath.
 Template templet(TemplateEngine templateEngine, MarkupLanguage markupLanguage, java.lang.String purpose, java.lang.String name)
          Get a templet by name, with optional purpose.
protected static java.lang.String templetsPath(TemplateEngine templateEngine, MarkupLanguage markupLanguage)
           
protected static java.lang.String templetsTempletPath(TemplateEngine templateEngine, MarkupLanguage markupLanguage, java.lang.String purpose, java.lang.String name)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static ClassNameTempletLoader getInstance()
Returns:
the instance

templetsPath

protected static java.lang.String templetsPath(TemplateEngine templateEngine,
                                               MarkupLanguage markupLanguage)

templetsTempletPath

protected static java.lang.String templetsTempletPath(TemplateEngine templateEngine,
                                                      MarkupLanguage markupLanguage,
                                                      java.lang.String purpose,
                                                      java.lang.String name)
Returns:
the path in the templets directory

classpathTempletPath

protected static java.lang.String classpathTempletPath(java.lang.Class clazz,
                                                       TemplateEngine templateEngine)

templet

public Template templet(TemplateEngine templateEngine,
                        MarkupLanguage markupLanguage,
                        java.lang.String purpose,
                        java.lang.String name)
                 throws java.io.IOException,
                        NotFoundException
Get a templet by name, with optional purpose. Return a templet by name and purpose.

Specified by:
templet in interface TempletLoader
Parameters:
templateEngine - the TemplateEngine in use
markupLanguage - the markuplanguage the templet is in
purpose - what the templet is for eg error
name - the name of the templet
Returns:
the templet
Throws:
java.io.IOException - if TemplateEngine does
NotFoundException - if template not found
See Also:
TempletLoader#templet(TemplateEngine, AbstractMarkupLanguage, String, String)

templet

public Template templet(TemplateEngine templateEngine,
                        MarkupLanguage markupLanguage,
                        java.lang.String name)
                 throws java.io.IOException,
                        NotFoundException
Get a templet by its name, looking only in the templets directory. Return a templet by name.

Specified by:
templet in interface TempletLoader
Parameters:
templateEngine - the TemplateEngine in use
markupLanguage - the markuplanguage the templet is in
name - the name of the templet
Returns:
the templet
Throws:
java.io.IOException - if TemplateEngine does
NotFoundException - if template not found
See Also:
TempletLoader.templet(TemplateEngine, MarkupLanguage, String)

templet

public Template templet(TemplateEngine templateEngine,
                        MarkupLanguage markupLanguage,
                        java.lang.String purpose,
                        java.lang.Class clazz)
                 throws TemplateEngineException,
                        java.io.IOException
Get a templet based upon class name and optional purpose, looking in the templets directory and also the classpath. Return a templet by Class and Purpose. The purpose search path is the normal search path with the purpose appended, separated by a "/". If there is no template found then the normal search path is searched. The purpose is then re-appended to the supperclasses searchpath and so on up the tree, stopping at Object, which is always found.

Specified by:
templet in interface TempletLoader
Parameters:
templateEngine - the TemplateEngine in use
markupLanguage - the markuplanguage the templet is in
purpose - what the templet is for eg error
clazz - Class that templet renders
Returns:
the templet
Throws:
java.io.IOException - if TemplateEngine does
TemplateEngineException
See Also:
TempletLoader.templet(TemplateEngine, MarkupLanguage, String, Class)

templet

public Template templet(TemplateEngine templateEngine,
                        MarkupLanguage markupLanguage,
                        java.lang.Class clazz)
                 throws java.io.IOException
Get a templet for a class. Return a templet for a given class, looking for a template with the same name as the class in the Melati templet directory; giving a full template path as: org/melati/template/TEMPLATE_ENGINE_NAME/MARKUP_LANGUAGE/java.lang.Object.wm which is the lowest possible template and is always found. The template is also looked for in the resource directory for that class. The search results are cached, so that searches are not repeated.

Specified by:
templet in interface TempletLoader
Parameters:
templateEngine - the TemplateEngine in use
markupLanguage - the markuplanguage the templet is in
clazz - the class name to translate into a template name
Returns:
the templet
Throws:
java.io.IOException - if TemplateEngine does
See Also:
TempletLoader.templet(TemplateEngine, MarkupLanguage, Class)

templet

public Template templet(TemplateEngine templateEngine,
                        MarkupLanguage markupLanguage,
                        FieldAttributes attributes)
                 throws java.io.IOException
Get a templet either from the FieldAttributes or the class name. Return a templet to render a Field.

Specified by:
templet in interface TempletLoader
Parameters:
templateEngine - the TemplateEngine in use
markupLanguage - the markuplanguage the templet is in
attributes - a FieldAttributes the templet is for eg a Field
Returns:
the templet
Throws:
java.io.IOException - if TemplateEngine does
See Also:
TempletLoader.templet(TemplateEngine,MarkupLanguage,FieldAttributes)


Copyright © 2000-2008 PanEris. All Rights Reserved.