Package org.apache.wicket.util.template
Class TextTemplateDecorator
- 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.TextTemplateDecorator
-
- All Implemented Interfaces:
Closeable
,Serializable
,AutoCloseable
,IClusterable
,IResourceStream
,IStringResourceStream
,IModifiable
- Direct Known Subclasses:
CssTemplate
,JavaScriptTemplate
public abstract class TextTemplateDecorator extends TextTemplate
Provides the ability to 'decorate' the actual template contents before it is contributed to the header. For example, to embed it inside a JavaScript tag pair.- Since:
- 1.2.6
- Author:
- Eelco Hillenius
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected TextTemplate
decorated
The decoratedTextTemplate
.-
Fields inherited from class org.apache.wicket.util.resource.AbstractStringResourceStream
DEFAULT_CONTENT_TYPE
-
-
Constructor Summary
Constructors Constructor Description TextTemplateDecorator(TextTemplate textTemplate)
Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description String
asString()
Returns the decorated contents as aString
.String
asString(Map<String,?> variables)
Returns the decorated contents as aString
.void
close()
Closes the resource.boolean
equals(Object obj)
abstract String
getAfterTemplateContents()
Retrieves theString
to put after the actual template contents, for example:abstract String
getBeforeTemplateContents()
Retrieves theString
to put before the actual template contents, for example:String
getContentType()
Gets the mime type of this resourceInputStream
getInputStream()
Gets the resource stream.Locale
getLocale()
String
getString()
Retrieves theString
resource.int
hashCode()
Instant
lastModifiedTime()
Gets the last time this modifiable thing changed.void
setCharset(Charset charset)
Sets the character set used for reading this resource.void
setLastModified(Instant lastModified)
void
setLocale(Locale locale)
This method shouldn't be used from the outside.String
toString()
-
Methods inherited from class org.apache.wicket.util.template.TextTemplate
interpolate
-
Methods inherited from class org.apache.wicket.util.resource.AbstractStringResourceStream
getCharset, length
-
Methods inherited from class org.apache.wicket.util.resource.AbstractResourceStream
getStyle, getVariation, setStyle, setVariation
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.wicket.util.resource.IResourceStream
getStyle, getVariation, setStyle, setVariation
-
-
-
-
Field Detail
-
decorated
protected final TextTemplate decorated
The decoratedTextTemplate
.
-
-
Constructor Detail
-
TextTemplateDecorator
public TextTemplateDecorator(TextTemplate textTemplate)
Constructor.- Parameters:
textTemplate
- aTextTemplate
to decorate
-
-
Method Detail
-
asString
public String asString()
Returns the decorated contents as aString
.- Specified by:
asString
in interfaceIStringResourceStream
- Overrides:
asString
in classTextTemplate
- Returns:
- the contents decorated with
getBeforeTemplateContents()
andgetAfterTemplateContents()
- See Also:
TextTemplate.asString()
-
asString
public String asString(Map<String,?> variables)
Returns the decorated contents as aString
.- Overrides:
asString
in classTextTemplate
- Parameters:
variables
- the variables to interpolate- Returns:
- the contents decorated with
getBeforeTemplateContents()
andgetAfterTemplateContents()
. - See Also:
TextTemplate.asString(java.util.Map)
-
getBeforeTemplateContents
public abstract String getBeforeTemplateContents()
Retrieves theString
to put before the actual template contents, for example:<script type="text/javascript">
- Returns:
- the
String
to put before the actual template contents
-
getAfterTemplateContents
public abstract String getAfterTemplateContents()
Retrieves theString
to put after the actual template contents, for example:</script>
- Returns:
- the
String
to put after the actual template contents
-
close
public void close() throws IOException
Description copied from interface:IResourceStream
Closes the resource. Normally, this includes closing any underlying input stream returned by getInputStream().- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceIResourceStream
- Overrides:
close
in classAbstractStringResourceStream
- Throws:
IOException
- See Also:
IResourceStream.close()
-
getContentType
public String getContentType()
Description copied from interface:IResourceStream
Gets the mime type of this resource- Specified by:
getContentType
in interfaceIResourceStream
- Overrides:
getContentType
in classAbstractStringResourceStream
- Returns:
- The mime type of this resource, such as "image/jpeg" or "text/html". Return null to let ResourceStreamRequestHandler handle the Content-Type automatically
- See Also:
IResourceStream.getContentType()
-
getInputStream
public InputStream getInputStream() throws ResourceStreamNotFoundException
Description copied from interface:IResourceStream
Gets the resource stream. You should not directly close this stream. Instead call the close() method on IResourceStream.- Specified by:
getInputStream
in interfaceIResourceStream
- Overrides:
getInputStream
in classAbstractStringResourceStream
- Returns:
- Returns the inputStream.
- Throws:
ResourceStreamNotFoundException
- See Also:
IResourceStream.getInputStream()
-
getLocale
public Locale getLocale()
- Specified by:
getLocale
in interfaceIResourceStream
- Overrides:
getLocale
in classAbstractResourceStream
- Returns:
- The Locale where this stream did resolve to
-
lastModifiedTime
public Instant lastModifiedTime()
Description copied from interface:IModifiable
Gets the last time this modifiable thing changed.- Specified by:
lastModifiedTime
in interfaceIModifiable
- Overrides:
lastModifiedTime
in classAbstractStringResourceStream
- Returns:
- the last modification
Time
ornull
if that information is not available - See Also:
IModifiable.lastModifiedTime()
-
setCharset
public void setCharset(Charset charset)
Description copied from class:AbstractStringResourceStream
Sets the character set used for reading this resource.- Specified by:
setCharset
in interfaceIStringResourceStream
- Overrides:
setCharset
in classAbstractStringResourceStream
- Parameters:
charset
- Charset for component
-
setLastModified
public void setLastModified(Instant lastModified)
- Overrides:
setLastModified
in classAbstractStringResourceStream
- Parameters:
lastModified
- The lastModified to set.
-
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.
-
getString
public String getString()
Description copied from class:TextTemplate
Retrieves theString
resource.- Specified by:
getString
in classTextTemplate
- Returns:
- the
String
resource
-
-