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:
Closeable
,Serializable
,AutoCloseable
,IClusterable
,IResourceStream
,IStringResourceStream
,IModifiable
public class PackageTextTemplate extends TextTemplate
AString
resource 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 String
DEFAULT_CONTENT_TYPE
The content type used if not provided in the constructorstatic String
DEFAULT_ENCODING
The encoding used if not provided in the constructor
-
Constructor Summary
Constructors Constructor Description PackageTextTemplate(Class<?> clazz, String fileName)
Constructor.PackageTextTemplate(Class<?> clazz, String fileName, String contentType)
Constructor.PackageTextTemplate(Class<?> clazz, String fileName, String contentType, String encoding)
Constructor.PackageTextTemplate(Class<?> clazz, String fileName, String style, String variation, Locale locale, String contentType, String encoding)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getString()
Retrieves theString
resource.TextTemplate
interpolate(Map<String,?> variables)
Interpolates aMap
of variables with the content and replaces the content with the result.void
setEncoding(String encoding)
void
setLocale(Locale locale)
This method shouldn't be used from the outside.void
setStyle(String style)
This method shouldn't be used from the outside.void
setVariation(String variation)
This method shouldn't be used from the outside.-
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
-
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
-
-
-
-
Field Detail
-
DEFAULT_CONTENT_TYPE
public static final String DEFAULT_CONTENT_TYPE
The content type used if not provided in the constructor- See Also:
- Constant Field Values
-
DEFAULT_ENCODING
public static final String DEFAULT_ENCODING
The encoding used if not provided in the constructor
-
-
Constructor Detail
-
PackageTextTemplate
public PackageTextTemplate(Class<?> clazz, String fileName)
Constructor.- Parameters:
clazz
- theClass
to be used for retrieving the classloader for loading thePackagedTextTemplate
fileName
- the name of the file, relative to theclazz
position
-
PackageTextTemplate
public PackageTextTemplate(Class<?> clazz, String fileName, String contentType)
Constructor.- Parameters:
clazz
- theClass
to be used for retrieving the classloader for loading thePackagedTextTemplate
fileName
- the name of the file, relative to theclazz
positioncontentType
- the mime type of this resource, such as "image/jpeg
" or "text/html
"
-
PackageTextTemplate
public PackageTextTemplate(Class<?> clazz, String fileName, String contentType, String encoding)
Constructor.- Parameters:
clazz
- theClass
to be used for retrieving the classloader for loading thePackagedTextTemplate
fileName
- the name of the file, relative to theclazz
positioncontentType
- 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(Class<?> clazz, String fileName, String style, String variation, Locale locale, String contentType, String encoding)
Constructor.- Parameters:
clazz
- theClass
to be used for retrieving the classloader for loading thePackagedTextTemplate
fileName
- the name of the file, relative to theclazz
positionstyle
- 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(String style)
Description copied from interface:IResourceStream
This method shouldn't be used from the outside. It is used by the Loaders to set the resolved Style.- Specified by:
setStyle
in interfaceIResourceStream
- Overrides:
setStyle
in classAbstractResourceStream
- Parameters:
style
- The style where this stream did resolve to.
-
setLocale
public void setLocale(Locale locale)
Description copied from interface:IResourceStream
This method shouldn't be used from the outside. It is used by the Loaders to set the resolved locale.- Specified by:
setLocale
in interfaceIResourceStream
- Overrides:
setLocale
in classAbstractResourceStream
- Parameters:
locale
- The Locale where this stream did resolve to.
-
setVariation
public void setVariation(String variation)
Description copied from interface:IResourceStream
This method shouldn't be used from the outside. It is used by the Loaders to set the resolved variation.- Specified by:
setVariation
in interfaceIResourceStream
- Overrides:
setVariation
in classAbstractResourceStream
- Parameters:
variation
- The Variation where this stream did resolve to.
-
setEncoding
public void setEncoding(String encoding)
-
getString
public String getString()
Description copied from class:TextTemplate
Retrieves theString
resource.- Specified by:
getString
in classTextTemplate
- Returns:
- the
String
resource - See Also:
AbstractStringResourceStream.getString()
-
interpolate
public final TextTemplate interpolate(Map<String,?> variables)
Interpolates aMap
of variables with the content and replaces the content with the result. Variables are denoted in theString
by 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:
interpolate
in classTextTemplate
- Parameters:
variables
- aMap
of variables to interpolate- Returns:
- this for chaining
-
-