org.melati.template
Class ClassNameTempletLoader

Package class diagram package ClassNameTempletLoader
java.lang.Object
  extended by org.melati.template.ClassNameTempletLoader
All Implemented Interfaces:
TempletLoader

public final class ClassNameTempletLoader
extends Object
implements TempletLoader

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


Method Summary
protected static String classpathTempletPath(Class<?> clazz, TemplateEngine templateEngine)
           
static ClassNameTempletLoader getInstance()
           
 Template templet(TemplateEngine templateEngine, MarkupLanguage markupLanguage, Class<?> clazz)
          Get a templet for a class.
 Template templet(TemplateEngine templateEngine, MarkupLanguage markupLanguage, FieldAttributes attributes)
          Get a templet either from the classname concatenated with FieldAttributes.RenederInfo or the class name.
 Template templet(TemplateEngine templateEngine, MarkupLanguage markupLanguage, String name)
          Get a templet by its name, looking only in the templets directory.
 Template templet(TemplateEngine templateEngine, MarkupLanguage markupLanguage, String purpose, 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, String purpose, String name)
          Get a templet by name, with optional purpose.
protected static String templetsPath(TemplateEngine templateEngine, MarkupLanguage markupLanguage)
           
protected static String templetsTempletPath(TemplateEngine templateEngine, MarkupLanguage markupLanguage, String purpose, 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 String templetsPath(TemplateEngine templateEngine,
                                     MarkupLanguage markupLanguage)

templetsTempletPath

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

classpathTempletPath

protected static String classpathTempletPath(Class<?> clazz,
                                             TemplateEngine templateEngine)

templet

public Template templet(TemplateEngine templateEngine,
                        MarkupLanguage markupLanguage,
                        String purpose,
                        String name)
                 throws 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:
NotFoundException - if template not found
See Also:
TempletLoader#templet(TemplateEngine, AbstractMarkupLanguage, String, String)

templet

public Template templet(TemplateEngine templateEngine,
                        MarkupLanguage markupLanguage,
                        String name)
                 throws 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:
NotFoundException - if template not found
See Also:
TempletLoader.templet(TemplateEngine, MarkupLanguage, String)

templet

public Template templet(TemplateEngine templateEngine,
                        MarkupLanguage markupLanguage,
                        String purpose,
                        Class<?> clazz)
                 throws TemplateEngineException
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:
TemplateEngineException
See Also:
TempletLoader.templet(TemplateEngine, MarkupLanguage, String, Class)

templet

public Template templet(TemplateEngine templateEngine,
                        MarkupLanguage markupLanguage,
                        Class<?> clazz)
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
See Also:
TempletLoader.templet(TemplateEngine, MarkupLanguage, Class)

templet

public Template templet(TemplateEngine templateEngine,
                        MarkupLanguage markupLanguage,
                        FieldAttributes attributes)
Get a templet either from the classname concatenated with FieldAttributes.RenederInfo 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
See Also:
TempletLoader.templet(TemplateEngine,MarkupLanguage,FieldAttributes)


Copyright © 2000-2010 PanEris. All Rights Reserved.