simple.template
Interface Document

All Superinterfaces:
Database
All Known Subinterfaces:
Panel

public interface Document
extends Database

A Document 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 in dependant manner. This achieves two things, it ensures that the controller is not tightly coupled to the templating system and ensures that familiarity with the templating system's API is not required.

Author:
Niall Gallagher

Method Summary
 java.lang.String getContentType()
          The content that is dynamically generated by the object is written as a specific MIME type, including charset information which determines the content encoding.
 java.lang.String toString()
          Produces the generated template output as a string.
 void write(java.io.OutputStream out)
          Displays the contents of the generated template output to the OutputStream.
 
Methods inherited from interface simple.template.Database
contains, get, keySet, put, remove
 

Method Detail

write

void write(java.io.OutputStream out)
           throws java.lang.Exception
Displays the contents of the generated template output to the OutputStream. 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. The output is written using the UTF-8 charset.

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()
The content that is dynamically generated by the object is written as a specific MIME type, including charset information which determines the content encoding. For example if the output was HTML written using UTF-8 format then this would return "text/html; charset=utf-8".

Returns:
returns the MIME type of the generated content

toString

java.lang.String toString()
Produces the generated template output as a string. This is useful for embedding documents within each other creating a layout effect. For example, if a templated HTML page required content from different sources, then a document could be added, as a property, for display.

This is very useful if the output is to be used as an SQL query, or an email message. The rendering is stored conveniently for use as a string and does not require an OutputStream to capture the output.

Overrides:
toString in class java.lang.Object
Returns:
document output if successful, null otherwise