Class PackageTextTemplate

  • 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

    public class PackageTextTemplate
    extends TextTemplate
    A String resource that can be appended to.
    Since:
    1.2.6
    Author:
    Eelco Hillenius
    See Also:
    Serialized Form
    • Constructor Detail

      • PackageTextTemplate

        public PackageTextTemplate​(Class<?> clazz,
                                   String fileName)
        Constructor.
        Parameters:
        clazz - the Class to be used for retrieving the classloader for loading the PackagedTextTemplate
        fileName - the name of the file, relative to the clazz position
      • PackageTextTemplate

        public PackageTextTemplate​(Class<?> clazz,
                                   String fileName,
                                   String contentType)
        Constructor.
        Parameters:
        clazz - the Class to be used for retrieving the classloader for loading the PackagedTextTemplate
        fileName - the name of the file, relative to the clazz position
        contentType - 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 - the Class to be used for retrieving the classloader for loading the PackagedTextTemplate
        fileName - the name of the file, relative to the clazz position
        contentType - 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 - the Class to be used for retrieving the classloader for loading the PackagedTextTemplate
        fileName - the name of the file, relative to the clazz position
        style - Any resource style, such as a skin style (see Session)
        variation - The template's variation (of the style)
        locale - The locale of the resource to load
        contentType - 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)
        Specified by:
        setStyle in interface org.apache.wicket.util.resource.IResourceStream
        Overrides:
        setStyle in class org.apache.wicket.util.resource.AbstractResourceStream
      • setLocale

        public void setLocale​(Locale locale)
        Specified by:
        setLocale in interface org.apache.wicket.util.resource.IResourceStream
        Overrides:
        setLocale in class org.apache.wicket.util.resource.AbstractResourceStream
      • setVariation

        public void setVariation​(String variation)
        Specified by:
        setVariation in interface org.apache.wicket.util.resource.IResourceStream
        Overrides:
        setVariation in class org.apache.wicket.util.resource.AbstractResourceStream
      • getString

        public String getString()
        Description copied from class: TextTemplate
        Retrieves the String resource.
        Specified by:
        getString in class TextTemplate
        Returns:
        the String resource
        See Also:
        AbstractStringResourceStream.getString()
      • interpolate

        public final TextTemplate interpolate​(Map<String,​?> variables)
        Interpolates a Map of variables with the content and replaces the content with the result. Variables are denoted in the 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").

        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 class TextTemplate
        Parameters:
        variables - a Map of variables to interpolate
        Returns:
        this for chaining