Package org.apache.wicket.util.template
Class TextTemplate
java.lang.Object
org.apache.wicket.util.resource.AbstractResourceStream
org.apache.wicket.util.resource.AbstractStringResourceStream
org.apache.wicket.util.template.TextTemplate
- All Implemented Interfaces:
Closeable
,Serializable
,AutoCloseable
,IClusterable
,IResourceStream
,IStringResourceStream
,IModifiable
- Direct Known Subclasses:
PackageTextTemplate
,TextTemplateDecorator
Represents a text template that can do variable interpolation.
- Since:
- 1.2.6
- Author:
- Eelco Hillenius, Jonathan Locke
- See Also:
-
Field Summary
Fields inherited from class org.apache.wicket.util.resource.AbstractStringResourceStream
DEFAULT_CONTENT_TYPE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionasString()
Interpolates theMap
of variables with the content and returns the resultingString
without replacing the content.abstract String
Retrieves theString
resource.abstract TextTemplate
interpolate
(Map<String, ?> variables) Interpolates values into thisTextTemplate
.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
-
Constructor Details
-
TextTemplate
public TextTemplate()Constructor. -
TextTemplate
Constructor.- Parameters:
contentType
- the mime type of this resource, such as "image/jpeg
" or "text/html
"
-
-
Method Details
-
asString
Interpolates theMap
of variables with the content and returns the resultingString
without replacing the content. 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 byvariables.getValue("variableName")
.- Parameters:
variables
- the variables to interpolate- Returns:
- the result of the interpolation
-
asString
- Specified by:
asString
in interfaceIStringResourceStream
- Overrides:
asString
in classAbstractStringResourceStream
- See Also:
-
getString
Retrieves theString
resource.- Specified by:
getString
in classAbstractStringResourceStream
- Returns:
- the
String
resource
-
interpolate
Interpolates values into thisTextTemplate
.- Parameters:
variables
- variables to interpolate into thisTextTemplate
- Returns:
this
, for chaining purposes
-