Package org.apache.wicket.util.template
Class PackageTextTemplate
- java.lang.Object
-
- org.apache.wicket.util.resource.AbstractResourceStream
-
- org.apache.wicket.util.resource.AbstractStringResourceStream
-
- org.apache.wicket.util.template.TextTemplate
-
- org.apache.wicket.util.template.PackageTextTemplate
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Serializable,java.lang.AutoCloseable,org.apache.wicket.util.io.IClusterable,org.apache.wicket.util.resource.IResourceStream,org.apache.wicket.util.resource.IStringResourceStream,org.apache.wicket.util.watch.IModifiable
public class PackageTextTemplate extends TextTemplate
AStringresource that can be appended to.- Since:
- 1.2.6
- Author:
- Eelco Hillenius
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDEFAULT_CONTENT_TYPEThe content type used if not provided in the constructorstatic java.lang.StringDEFAULT_ENCODINGThe encoding used if not provided in the constructor
-
Constructor Summary
Constructors Constructor Description 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.PackageTextTemplate(java.lang.Class<?> clazz, java.lang.String fileName, java.lang.String style, java.lang.String variation, java.util.Locale locale, java.lang.String contentType, java.lang.String encoding)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetString()Retrieves theStringresource.TextTemplateinterpolate(java.util.Map<java.lang.String,?> variables)Interpolates aMapof variables with the content and replaces the content with the result.voidsetEncoding(java.lang.String encoding)voidsetLocale(java.util.Locale locale)voidsetStyle(java.lang.String style)voidsetVariation(java.lang.String variation)-
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
-
-
-
-
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- theClassto be used for retrieving the classloader for loading thePackagedTextTemplatefileName- the name of the file, relative to theclazzposition
-
PackageTextTemplate
public PackageTextTemplate(java.lang.Class<?> clazz, java.lang.String fileName, java.lang.String contentType)Constructor.- Parameters:
clazz- theClassto be used for retrieving the classloader for loading thePackagedTextTemplatefileName- the name of the file, relative to theclazzpositioncontentType- 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- theClassto be used for retrieving the classloader for loading thePackagedTextTemplatefileName- the name of the file, relative to theclazzpositioncontentType- the mime type of this resource, such as "image/jpeg" or "text/html"encoding- the file's encoding, for example, "UTF-8"
-
PackageTextTemplate
public PackageTextTemplate(java.lang.Class<?> clazz, java.lang.String fileName, java.lang.String style, java.lang.String variation, java.util.Locale locale, java.lang.String contentType, java.lang.String encoding)Constructor.- Parameters:
clazz- theClassto be used for retrieving the classloader for loading thePackagedTextTemplatefileName- the name of the file, relative to theclazzpositionstyle- Any resource style, such as a skin style (seeSession)variation- The template's variation (of the style)locale- The locale of the resource to loadcontentType- the mime type of this resource, such as "image/jpeg" or "text/html"encoding- the file's encoding, for example, "UTF-8"
-
-
Method Detail
-
setStyle
public void setStyle(java.lang.String style)
- Specified by:
setStylein interfaceorg.apache.wicket.util.resource.IResourceStream- Overrides:
setStylein classorg.apache.wicket.util.resource.AbstractResourceStream
-
setLocale
public void setLocale(java.util.Locale locale)
- Specified by:
setLocalein interfaceorg.apache.wicket.util.resource.IResourceStream- Overrides:
setLocalein classorg.apache.wicket.util.resource.AbstractResourceStream
-
setVariation
public void setVariation(java.lang.String variation)
- Specified by:
setVariationin interfaceorg.apache.wicket.util.resource.IResourceStream- Overrides:
setVariationin classorg.apache.wicket.util.resource.AbstractResourceStream
-
setEncoding
public void setEncoding(java.lang.String encoding)
-
getString
public java.lang.String getString()
Description copied from class:TextTemplateRetrieves theStringresource.- Specified by:
getStringin classTextTemplate- Returns:
- the
Stringresource - See Also:
AbstractStringResourceStream.getString()
-
interpolate
public final TextTemplate interpolate(java.util.Map<java.lang.String,?> variables)
Interpolates aMapof variables with the content and replaces the content with the result. Variables are denoted in theStringby thesyntax ${variableName}. The contents will be altered by replacing each variable of the form${variableName}with the value returned byvariables.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:
interpolatein classTextTemplate- Parameters:
variables- aMapof variables to interpolate- Returns:
- this for chaining
-
-