Class TextTemplate

  • All Implemented Interfaces:
    Closeable, Serializable, 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
    Direct Known Subclasses:
    PackageTextTemplate, TextTemplateDecorator

    public abstract class TextTemplate
    extends org.apache.wicket.util.resource.AbstractStringResourceStream
    Represents a text template that can do variable interpolation.
    Since:
    1.2.6
    Author:
    Eelco Hillenius, Jonathan Locke
    See Also:
    VariableInterpolator, Serialized Form
    • Field Summary

      • Fields inherited from class org.apache.wicket.util.resource.AbstractStringResourceStream

        DEFAULT_CONTENT_TYPE
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      String asString()  
      String asString​(Map<String,​?> variables)
      Interpolates the Map of variables with the content and returns the resulting String without replacing the content.
      abstract String getString()
      Retrieves the String resource.
      abstract TextTemplate interpolate​(Map<String,​?> variables)
      Interpolates values into this TextTemplate.
      • 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 interface org.apache.wicket.util.resource.IResourceStream

        getLocale, getStyle, getVariation, setLocale, setStyle, setVariation
    • Constructor Detail

      • TextTemplate

        public TextTemplate()
        Constructor.
      • TextTemplate

        public TextTemplate​(String contentType)
        Constructor.
        Parameters:
        contentType - the mime type of this resource, such as "image/jpeg" or " text/html"
    • Method Detail

      • asString

        public String asString​(Map<String,​?> variables)
        Interpolates the Map of variables with the content and returns the resulting String 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 by variables.getValue("variableName").
        Parameters:
        variables - the variables to interpolate
        Returns:
        the result of the interpolation
      • asString

        public String asString()
        Specified by:
        asString in interface org.apache.wicket.util.resource.IStringResourceStream
        Overrides:
        asString in class org.apache.wicket.util.resource.AbstractStringResourceStream
        See Also:
        AbstractStringResourceStream.asString()
      • getString

        public abstract String getString()
        Retrieves the String resource.
        Specified by:
        getString in class org.apache.wicket.util.resource.AbstractStringResourceStream
        Returns:
        the String resource
      • interpolate

        public abstract TextTemplate interpolate​(Map<String,​?> variables)
        Interpolates values into this TextTemplate.
        Parameters:
        variables - variables to interpolate into this TextTemplate
        Returns:
        this, for chaining purposes