simple.template.layout
Interface Viewer

All Superinterfaces:
Database

public interface Viewer
extends Database

A Viewer object represents a template with a set of properties. This represents a template loaded from some source that can have specific properties set to configure a rendering of the template acquired from the templating system.

This interface attempts to encapsulate the functionality provided by the templating system in an independant manner. This achieves two things, it ensures that the controller is not tightly coupled to the templating system and ensures that firmiliarity with the templating system's API is not required.

Author:
Niall Gallagher

Method Summary
 java.lang.String getCharset()
          This provides the character encoding of the page.
 java.lang.String getContentType()
          This is used to acquire a HTTP Content-Type header, which can be used to describe the contents of the viewer.
 void write(java.io.PrintWriter out)
          Displays the contents of the generated template output to the issued Writer.
 
Methods inherited from interface simple.template.Database
contains, get, keySet, put, remove
 

Method Detail

write

void write(java.io.PrintWriter out)
           throws java.lang.Exception
Displays the contents of the generated template output to the issued Writer. This encapsulates the means of rendering the template to a single method. Internally the properties that are set within the document will be used to configure the template, enabling dynamic output.

If there are any problems parsing the template or emitting its contents an exception is thrown. However, if it is successfully processed it will be written to the issued output, which should remain unflushed for performance.

Parameters:
out - the output to write the template rendering to
Throws:
java.lang.Exception - thrown if there is a problem parsing or emitting the template

getContentType

java.lang.String getContentType()
This is used to acquire a HTTP Content-Type header, which can be used to describe the contents of the viewer. This will typically be the MIME type and character set of the template, for example "text/html; charset=UTF-8". This is provided so that the document can describe the type.

Returns:
this returns the content type of the contents

getCharset

java.lang.String getCharset()
This provides the character encoding of the page. This is typically UTF-8, however it can be any supported character encoding for the Java platform. This is used to ensure the conversion from characters to bytes is known.

Returns:
this returns the character encoding of the page