org.apache.wicket.util.template
Class TextTemplate

java.lang.Object
  extended by org.apache.wicket.util.resource.AbstractResourceStream
      extended by org.apache.wicket.util.resource.AbstractStringResourceStream
          extended by org.apache.wicket.util.template.TextTemplate
All Implemented Interfaces:
java.io.Serializable, IClusterable, IResourceStream, IStringResourceStream, IModifiable
Direct Known Subclasses:
PackagedTextTemplate, TextTemplateDecorator

public abstract class TextTemplate
extends AbstractStringResourceStream

Represents a text template that can do variable interpolation.

Since:
1.2.6
Author:
Eelco Hillenius, Jonathan Locke
See Also:
VariableInterpolator, Serialized Form

Constructor Summary
TextTemplate()
          Constructor.
TextTemplate(java.lang.String contentType)
          Constructor.
 
Method Summary
 java.lang.String asString()
           
 java.lang.String asString(java.util.Map variables)
          Interpolates the Map of variables with the content and returns the resulting String without replacing the content.
abstract  java.lang.String getString()
          Retrieves the String resource.
abstract  TextTemplate interpolate(java.util.Map variables)
          Interpolates values into this TextTemplate.
 
Methods inherited from class org.apache.wicket.util.resource.AbstractStringResourceStream
close, getContentType, getInputStream, lastModifiedTime, setLastModified
 
Methods inherited from class org.apache.wicket.util.resource.AbstractResourceStream
getCharset, getLocale, length, setCharset, setLocale
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextTemplate

public TextTemplate()
Constructor.


TextTemplate

public TextTemplate(java.lang.String contentType)
Constructor.

Parameters:
contentType - the mime type of this resource, such as "image/jpeg" or "text/html"
Method Detail

asString

public java.lang.String asString(java.util.Map variables)
Interpolates the Map of variables with the content and returns the resulting String without replacing the content. Variables are denoted in this string by the syntax ${variableName}. The contents will be altered by replacing each variable of the form ${variableName} with the value returned by variables.getValue("variableName").

Parameters:
variables - the variables to interpolate
Returns:
the result of the interpolation

asString

public java.lang.String asString()
Specified by:
asString in interface IStringResourceStream
Overrides:
asString in class AbstractResourceStream
Returns:
This resource as a String.
See Also:
AbstractResourceStream.asString()

getString

public abstract java.lang.String getString()
Retrieves the String resource.

Specified by:
getString in class AbstractStringResourceStream
Returns:
the String resource

interpolate

public abstract TextTemplate interpolate(java.util.Map variables)
Interpolates values into this TextTemplate.

Parameters:
variables - variables to interpolate into this TextTemplate
Returns:
this, for chaining purposes


Copyright © 2004-2010 Apache Software Foundation. All Rights Reserved.