fr.cnes.sitools.util
Class TemplateUtils

java.lang.Object
  extended by fr.cnes.sitools.util.TemplateUtils

public final class TemplateUtils
extends java.lang.Object

Freemarker template utilities

Author:
jp.boignard (AKKA Technologies)

Method Summary
static void describeClassForTemplate(java.lang.String entry, java.lang.Class<?> classe, java.lang.StringBuffer buffer)
          To produce a description of fields that can be used in template
static void describeObjectClassesForTemplate(java.lang.String templatePath, java.util.Map<java.lang.String,java.lang.Object> objects)
          describeObjectClassesForTemplate
static java.lang.String mapToString(java.lang.String templatePath, java.util.Map<java.lang.String,java.lang.Object> map)
          To merge a template with a Map model.
static java.lang.String toString(java.lang.String templatePath, java.lang.Object object)
          To merge a template with an Object model.
static java.lang.String toStringWithObjectClasspathTemplate(java.lang.String templatePath, java.lang.Object object)
          Builds a String using FreeMarker template whose name is given in parameter.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

toStringWithObjectClasspathTemplate

public static java.lang.String toStringWithObjectClasspathTemplate(java.lang.String templatePath,
                                                                   java.lang.Object object)
Builds a String using FreeMarker template whose name is given in parameter. Template file is loaded from object class package

Parameters:
templatePath - the path to use
object - object to use
Returns:
String

mapToString

public static java.lang.String mapToString(java.lang.String templatePath,
                                           java.util.Map<java.lang.String,java.lang.Object> map)
To merge a template with a Map model.

Parameters:
templatePath - complete template ftl file name.
map - Map model
Returns:
String result of mapping.

toString

public static java.lang.String toString(java.lang.String templatePath,
                                        java.lang.Object object)
To merge a template with an Object model. Map form is recommended.

Parameters:
templatePath - complete template ftl file name.
object - Object model
Returns:
String result of mapping. TODO missing MediaType information (detection ?) of result. We could use the file extention .html or .xml ..., instead of .ftl. It needs to know the complete template file name in among of this function.

describeObjectClassesForTemplate

public static void describeObjectClassesForTemplate(java.lang.String templatePath,
                                                    java.util.Map<java.lang.String,java.lang.Object> objects)
describeObjectClassesForTemplate

Parameters:
templatePath - the template path
objects - the Map of Objects

describeClassForTemplate

public static void describeClassForTemplate(java.lang.String entry,
                                            java.lang.Class<?> classe,
                                            java.lang.StringBuffer buffer)
To produce a description of fields that can be used in template

Parameters:
entry - the String entry
classe - the class
buffer - the StringBuffer


Copyright © 2010-2013 CNES. All Rights Reserved.