NextApp Echo
App Container 1.1.4

nextapp.echoservlet
Class Template

java.lang.Object
  extended bynextapp.echoservlet.Template
All Implemented Interfaces:
java.io.Serializable, Service

public class Template
extends java.lang.Object
implements Service, java.io.Serializable

A service which produces templated text output. Templates are used in cases where the server must render a mostly static document that contains text that may vary. This service is similar to StaticText, but offers the ability to have dynamically inserted text at specified points. A dynamic area is specified by adding a "variable name" to the template. Variables names are enclosed in dollar signs.

The following example document shows how a Template can be used:

In the year $Year$, annual sales were $$$AnnualSales$.

This sample has two variables, "Year" and "Annual Sales". The double dollar sign will be rendered as a single dollar sign. The variable data will be extracted from the renderer's VariableData object.

See Also:
Serialized Form

Constructor Summary
Template(ContentType contentType, java.lang.String templateData)
          Deprecated. The Template(String, ContentType, String) constructor should be used instead. Use of this version may result in errors if applications are migrated between VMs, due to the Service having a different identifier on each VM.
Template(java.lang.String identifier, ContentType contentType, java.lang.String templateData)
          Creates a content template from the given String.
 
Method Summary
static Template createFromResource(java.lang.String resourceName)
          Deprecated. The createFromResource(String, String) method should be used instead. Use of this version may result in errors if applications are migrated between VMs, due to the Service having a different identifier on each VM.
static Template createFromResource(java.lang.String identifier, java.lang.String resourceName)
          Creates a Template object by way of a resource name.
 ContentType getContentType()
          Returns the content type.
 Id getId()
          Returns a unique identifier for this service.
 void service(Connection conn)
          Services an HTTP request.
 java.lang.String toString()
          Renders the content template as a String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Template

public Template(ContentType contentType,
                java.lang.String templateData)
Deprecated. The Template(String, ContentType, String) constructor should be used instead. Use of this version may result in errors if applications are migrated between VMs, due to the Service having a different identifier on each VM.

Creates a content template from the given String.

Parameters:
contentType - The content type of the output.
templateData - A String containing the template data.

Template

public Template(java.lang.String identifier,
                ContentType contentType,
                java.lang.String templateData)
Creates a content template from the given String.

Parameters:
contentType - The content type of the output.
templateData - A String containing the template data.
identifier - A unique identifier for this service.
Method Detail

createFromResource

public static Template createFromResource(java.lang.String resourceName)
Deprecated. The createFromResource(String, String) method should be used instead. Use of this version may result in errors if applications are migrated between VMs, due to the Service having a different identifier on each VM.

Creates a Template object by way of a resource name. The content type will be determined from the resource's extension. JavaScript resources will be compressed.

Parameters:
resourceName - The name of the resource from which to create the StaticText object.
Returns:
A Template object containing the content of the specified resource.

createFromResource

public static Template createFromResource(java.lang.String identifier,
                                          java.lang.String resourceName)
Creates a Template object by way of a resource name. The content type will be determined from the resource's extension. JavaScript resources will be compressed.

Parameters:
identifier - A unique identifier for this service.
resourceName - The name of the resource from which to create the StaticText object.
Returns:
A Template object containing the content of the specified resource.

getContentType

public ContentType getContentType()
Returns the content type.

Returns:
The content type.

getId

public Id getId()
Description copied from interface: Service
Returns a unique identifier for this service.

Specified by:
getId in interface Service
Returns:
A unique identifier for this service.
See Also:
Service.getId()

service

public void service(Connection conn)
             throws java.io.IOException
Description copied from interface: Service
Services an HTTP request. Information about the HTTP request as well as methods for issuing a response are available from the provided Connection object.

Specified by:
service in interface Service
Parameters:
conn - A Connection object which wraps HttpServletRequest and HttpServletResponse objects and provides access to the facilities of the Echo application container.
Throws:
java.io.IOException - in the event of errors related to processing the HTTP request or producing a response.
See Also:
Service.service(Connection)

toString

public java.lang.String toString()
Renders the content template as a String. Should be used only for debugging purposes.

Returns:
A String representation of the template.

NextApp Echo
App Container 1.1.4