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
A
String
resource that can be appended to.- Since:
- 1.2.6
- Author:
- Eelco Hillenius
- See Also:
-
Field Summary
-
Constructor Summary
ConstructorDescriptionPackageTextTemplate
(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
Modifier and TypeMethodDescriptionRetrieves theString
resource.final TextTemplate
interpolate
(Map<String, ?> variables) Interpolates aMap
of variables with the content and replaces the content with the result.void
setEncoding
(String encoding) void
This method shouldn't be used from the outside.void
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 Details
-
DEFAULT_CONTENT_TYPE
The content type used if not provided in the constructor- See Also:
-
DEFAULT_ENCODING
The encoding used if not provided in the constructor
-
-
Constructor Details
-
PackageTextTemplate
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
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
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 Details
-
setStyle
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
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
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
-
getString
Description copied from class:TextTemplate
Retrieves theString
resource.- Specified by:
getString
in classTextTemplate
- Returns:
- the
String
resource - See Also:
-
interpolate
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
-