org.codehaus.waffle.testing.view
Class ViewHarness

java.lang.Object
  extended by org.codehaus.waffle.testing.view.ViewHarness

public class ViewHarness
extends java.lang.Object

Facade that enable processing of views by different template engines. The choice of engine is made based on the extension of the template resource, eg .ftl will trigger use of Freemarker processor.

Author:
Mauro Talevi

Constructor Summary
ViewHarness()
           
ViewHarness(java.util.Properties configuration)
           
 
Method Summary
static java.lang.String decorateView(java.lang.String resource, java.lang.Object controller, java.lang.String decoratorsResource, java.lang.String decoratorName, java.util.Map<java.lang.String,java.lang.Object> decoratorDataModel)
          Decorates a view with Sitemesh and default processor configuration
static java.lang.String decorateView(java.lang.String resource, java.util.Properties configuration, java.lang.ClassLoader classLoader, java.lang.Object controller, java.lang.String decoratorsResource, java.lang.String decoratorName, java.util.Map<java.lang.String,java.lang.Object> decoratorDataModel)
          Decorates a view with Sitemesh and custom processor configuration
static void exportView(java.lang.String processed, java.io.File output)
          Exports a view to a file
static void exportView(java.lang.String processed, java.io.OutputStream output)
          Exports a view to an output stream
 java.lang.String process(java.lang.String resource, java.lang.Object controller)
           
 java.lang.String process(org.codehaus.waffle.testing.view.ViewHarness.Type type, java.lang.String resource, java.lang.Object controller)
           
 ViewProcessor processorFor(java.lang.String resource)
           
 ViewProcessor processorFor(org.codehaus.waffle.testing.view.ViewHarness.Type type)
           
static java.lang.String processView(java.lang.String resource, java.lang.Object controller, boolean debug)
          Processes a view with default configuration
static java.lang.String processView(java.lang.String resource, java.util.Properties configuration, java.lang.Object controller, boolean debug)
          Processes a view with custom configuration
 org.codehaus.waffle.testing.view.ViewHarness.Type typeFor(java.lang.String resource)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ViewHarness

public ViewHarness()

ViewHarness

public ViewHarness(java.util.Properties configuration)
Method Detail

process

public java.lang.String process(java.lang.String resource,
                                java.lang.Object controller)

process

public java.lang.String process(org.codehaus.waffle.testing.view.ViewHarness.Type type,
                                java.lang.String resource,
                                java.lang.Object controller)

processorFor

public ViewProcessor processorFor(java.lang.String resource)

processorFor

public ViewProcessor processorFor(org.codehaus.waffle.testing.view.ViewHarness.Type type)

typeFor

public org.codehaus.waffle.testing.view.ViewHarness.Type typeFor(java.lang.String resource)

processView

public static java.lang.String processView(java.lang.String resource,
                                           java.lang.Object controller,
                                           boolean debug)
Processes a view with default configuration

Parameters:
resource - the template resource path
controller - the controller instance
debug - the debug boolean flag
Returns:
The processed resource

processView

public static java.lang.String processView(java.lang.String resource,
                                           java.util.Properties configuration,
                                           java.lang.Object controller,
                                           boolean debug)
Processes a view with custom configuration

Parameters:
resource - the template resource path
configuration - the view processor configuration
controller - the controller instance
debug - the debug boolean flag
Returns:
The processed resource

decorateView

public static java.lang.String decorateView(java.lang.String resource,
                                            java.lang.Object controller,
                                            java.lang.String decoratorsResource,
                                            java.lang.String decoratorName,
                                            java.util.Map<java.lang.String,java.lang.Object> decoratorDataModel)
Decorates a view with Sitemesh and default processor configuration

Parameters:
resource - the template resource path
controller - the controller instance
decoratorsResource - the Sitemesh decorators resource
decoratorName - the decorator name
decoratorDataModel - the decorator data model that can be used to override the processor data model
Returns:
The decorated resource

decorateView

public static java.lang.String decorateView(java.lang.String resource,
                                            java.util.Properties configuration,
                                            java.lang.ClassLoader classLoader,
                                            java.lang.Object controller,
                                            java.lang.String decoratorsResource,
                                            java.lang.String decoratorName,
                                            java.util.Map<java.lang.String,java.lang.Object> decoratorDataModel)
Decorates a view with Sitemesh and custom processor configuration

Parameters:
resource - the template resource path
configuration - the view processor configuration
classLaoder - the ClassLoader used to load the decorator
controller - the controller instance
decoratorsResource - the Sitemesh decorators resource
decoratorName - the decorator name
decoratorDataModel - the decorator data model that can be used to override the processor data model
Returns:
The decorated resource

exportView

public static void exportView(java.lang.String processed,
                              java.io.File output)
                       throws java.io.IOException
Exports a view to a file

Parameters:
processed - the String encoding the processed view
output - the File to export view to
Throws:
java.io.IOException

exportView

public static void exportView(java.lang.String processed,
                              java.io.OutputStream output)
                       throws java.io.IOException
Exports a view to an output stream

Parameters:
processed - the String encoding the processed view
output - the OutputStream to export view to
Throws:
java.io.IOException


Copyright © 2008. All Rights Reserved.