org.apache.wicket.util.template
Class PackageTextTemplate

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
              extended by org.apache.wicket.util.template.PackageTextTemplate
All Implemented Interfaces:
java.io.Closeable, java.io.Serializable, IClusterable, IResourceStream, IStringResourceStream, IModifiable

public class PackageTextTemplate
extends TextTemplate

A String resource that can be appended to.

Since:
1.2.6
Author:
Eelco Hillenius
See Also:
Serialized Form

Field Summary
static java.lang.String DEFAULT_CONTENT_TYPE
          The content type used if not provided in the constructor
static java.lang.String DEFAULT_ENCODING
          The encoding used if not provided in the constructor
 
Constructor Summary
PackageTextTemplate(java.lang.Class<?> clazz, java.lang.String fileName)
          Constructor.
PackageTextTemplate(java.lang.Class<?> clazz, java.lang.String fileName, java.lang.String contentType)
          Constructor.
PackageTextTemplate(java.lang.Class<?> clazz, java.lang.String fileName, java.lang.String contentType, java.lang.String encoding)
          Constructor.
 
Method Summary
 java.lang.String getString()
          Retrieves the String resource.
 TextTemplate interpolate(java.util.Map<java.lang.String,?> variables)
          Interpolates a Map of variables with the content and replaces the content with the result.
 
Methods inherited from class org.apache.wicket.util.template.TextTemplate
asString, asString
 
Methods inherited from class org.apache.wicket.util.resource.AbstractStringResourceStream
close, getCharset, getContentType, getInputStream, lastModifiedTime, length, setCharset, setLastModified
 
Methods inherited from class org.apache.wicket.util.resource.AbstractResourceStream
getLocale, getStyle, getVariation, setLocale, setStyle, setVariation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.wicket.util.resource.IResourceStream
getLocale, getStyle, getVariation, setLocale, setStyle, setVariation
 

Field Detail

DEFAULT_CONTENT_TYPE

public static final java.lang.String DEFAULT_CONTENT_TYPE
The content type used if not provided in the constructor

See Also:
Constant Field Values

DEFAULT_ENCODING

public static final java.lang.String DEFAULT_ENCODING
The encoding used if not provided in the constructor

Constructor Detail

PackageTextTemplate

public PackageTextTemplate(java.lang.Class<?> clazz,
                           java.lang.String fileName)
Constructor.

Parameters:
clazz - the Class to be used for retrieving the classloader for loading the PackagedTextTemplate
fileName - the name of the file, relative to the clazz position

PackageTextTemplate

public PackageTextTemplate(java.lang.Class<?> clazz,
                           java.lang.String fileName,
                           java.lang.String contentType)
Constructor.

Parameters:
clazz - the Class to be used for retrieving the classloader for loading the PackagedTextTemplate
fileName - the name of the file, relative to the clazz position
contentType - the mime type of this resource, such as "image/jpeg" or " text/html"

PackageTextTemplate

public PackageTextTemplate(java.lang.Class<?> clazz,
                           java.lang.String fileName,
                           java.lang.String contentType,
                           java.lang.String encoding)
Constructor.

Parameters:
clazz - the Class to be used for retrieving the classloader for loading the PackagedTextTemplate
fileName - the name of the file, relative to the clazz position
contentType - the mime type of this resource, such as "image/jpeg" or " text/html"
encoding - the file's encoding, for example, "UTF-8"
Method Detail

getString

public java.lang.String getString()
Description copied from class: TextTemplate
Retrieves the String resource.

Specified by:
getString in class TextTemplate
Returns:
the String resource
See Also:
AbstractStringResourceStream.getString()

interpolate

public final TextTemplate interpolate(java.util.Map<java.lang.String,?> variables)
Interpolates a Map of variables with the content and replaces the content with the result. Variables are denoted in the 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").

WARNING: there is no going back to the original contents after the interpolation is done. If you need to do different interpolations on the same original contents, use the method TextTemplate.asString(Map) instead.

Specified by:
interpolate in class TextTemplate
Parameters:
variables - a Map of variables to interpolate
Returns:
this for chaining


Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.