it.geosolutions.tools.freemarker.filter
Class FreeMarkerFilter

java.lang.Object
  extended by it.geosolutions.tools.freemarker.filter.FreeMarkerFilter

public class FreeMarkerFilter
extends Object

A file filter processor used to filter a file obtaining a filtered document

Author:
Carlo Cancellieri - carlo.cancellieri@geo-solutions.it

Constructor Summary
FreeMarkerFilter(File template)
          Constructor
FreeMarkerFilter(File workingDir, Reader reader)
          Constructor
FreeMarkerFilter(String workingDir, Reader reader)
          Constructor
FreeMarkerFilter(String wd, String ifn)
          Constructor
 
Method Summary
 boolean isInitted()
          Check the status of this configuration
 boolean process(freemarker.template.TemplateModel root, Writer out)
          This method is used to process the file using this configuration
 freemarker.template.TemplateModel wrapRoot(Object tm)
          Try to wrap the passed object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FreeMarkerFilter

public FreeMarkerFilter(String wd,
                        String ifn)
                 throws IllegalArgumentException,
                        IOException
Constructor

Parameters:
wd - workingDir (Set the explicit directory from which to load templates)
ifn - [input file name] the template file name should be located into the wd
Throws:
IOException
IllegalArgumentException - Some arguments are null
See Also:
documentation for detailed accepted data types.

FreeMarkerFilter

public FreeMarkerFilter(File template)
                 throws IllegalArgumentException,
                        IOException
Constructor

Parameters:
the - input file (the template path)
Throws:
IOException
IllegalArgumentException - Some arguments are null
See Also:
documentation for detailed accepted data types.

FreeMarkerFilter

public FreeMarkerFilter(String workingDir,
                        Reader reader)
                 throws IllegalArgumentException,
                        IOException
Constructor

Parameters:
wd - workingDir (Set the explicit directory from which to load templates)
r - the reader of a FreeMarker template
Throws:
IOException
IllegalArgumentException - Some arguments are null
See Also:
documentation for detailed accepted data types.

FreeMarkerFilter

public FreeMarkerFilter(File workingDir,
                        Reader reader)
                 throws IllegalArgumentException,
                        IOException
Constructor

Parameters:
wd - workingDir (Set the explicit directory from which to load templates)
r - the reader of a FreeMarker template
Throws:
IOException
IllegalArgumentException - Some arguments are null
See Also:
documentation for detailed accepted data types.
Method Detail

wrapRoot

public freemarker.template.TemplateModel wrapRoot(Object tm)
                                           throws NullPointerException,
                                                  freemarker.template.TemplateModelException
Try to wrap the passed object

Parameters:
tm - the Object containing the TemplateModel to use as root data model TemplateHashModel TemplateSequenceModel TemplateCollectionModel TemplateScalarModel TemplateNumberModel TemplateTransformModel
Throws:
NullPointerException - if tm is null
freemarker.template.TemplateModelException - if defined objectWrapper can't wrap the passed object

isInitted

public boolean isInitted()
Check the status of this configuration

Returns:
true if the init() method has already run false otherwise

process

public boolean process(freemarker.template.TemplateModel root,
                       Writer out)
                throws freemarker.template.TemplateException,
                       IOException
This method is used to process the file using this configuration

Parameters:
out - the Writer
Returns:
true if success, false if the filter is not initialized
Throws:
freemarker.template.TemplateException - if an exception occurs during template processing
IOException - if an I/O exception occurs during writing to the writer.


Copyright © 2011-2012 GeoSolutions. All Rights Reserved.