wicket.extensions.util.resource
Class PackagedTextTemplate

java.lang.Object
  extended bywicket.util.resource.AbstractResourceStream
      extended bywicket.util.resource.AbstractStringResourceStream
          extended bywicket.extensions.util.resource.TextTemplate
              extended bywicket.extensions.util.resource.PackagedTextTemplate
All Implemented Interfaces:
wicket.util.watch.IModifiable, wicket.util.resource.IResourceStream, wicket.util.resource.IStringResourceStream, java.io.Serializable

public class PackagedTextTemplate
extends TextTemplate

A string resource that can be appended to.

Author:
Eelco Hillenius
See Also:
Serialized Form

Constructor Summary
PackagedTextTemplate(java.lang.Class clazz, java.lang.String fileName)
          Constructor.
PackagedTextTemplate(java.lang.Class clazz, java.lang.String fileName, java.lang.String contentType)
          Constructor.
PackagedTextTemplate(java.lang.Class clazz, java.lang.String fileName, java.lang.String contentType, java.lang.String encoding)
          Constructor.
 
Method Summary
 java.lang.String getString()
          Gets the string resource.
 TextTemplate interpolate(java.util.Map variables)
          Interpolate the map of variables with the content and replace the content with the result.
 long length()
           
 
Methods inherited from class wicket.extensions.util.resource.TextTemplate
asString, asString
 
Methods inherited from class wicket.util.resource.AbstractStringResourceStream
close, getContentType, getInputStream, lastModifiedTime, setLastModified
 
Methods inherited from class wicket.util.resource.AbstractResourceStream
getCharset, getLocale, setCharset, setLocale
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PackagedTextTemplate

public PackagedTextTemplate(java.lang.Class clazz,
                            java.lang.String fileName)
Constructor.

Parameters:
clazz - The class to be used for retrieving the classloader for loading the packaged template.
fileName - The name of the file, relative to the clazz position

PackagedTextTemplate

public PackagedTextTemplate(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 packaged template.
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"

PackagedTextTemplate

public PackagedTextTemplate(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 packaged template.
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, e.g. 'UTF-8'
Method Detail

interpolate

public final TextTemplate interpolate(java.util.Map variables)
Interpolate the map of variables with the content and replace the content with the result. 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").

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 method TextTemplate.asString(Map) instead.

Specified by:
interpolate in class TextTemplate
Parameters:
variables - The variables to interpolate
Returns:
This for chaining

length

public final long length()
See Also:
IResourceStream.length()

getString

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

Specified by:
getString in class TextTemplate
Returns:
The string resource
See Also:
AbstractStringResourceStream.getString()


Copyright © 2004-2008 Wicket developers. All Rights Reserved.