Class TemplateFilter

  • All Implemented Interfaces:
    Uniform

    public class TemplateFilter
    extends Filter
    Filter response's entity and wrap it with a Velocity's template representation. By default, the template representation provides a data model based on the request and response objects. In order for the wrapping to happen, the representations must have the Encoding.VELOCITY encoding set.

    Concurrency note: instances of this class or its subclasses can be invoked by several threads at the same time and therefore must be thread-safe. You should be especially careful when storing state in member variables.
    • Field Detail

      • mapDataModel

        private volatile java.util.Map<java.lang.String,​java.lang.Object> mapDataModel
        The template's data model as a map.
      • resolverDataModel

        private volatile Resolver<java.lang.Object> resolverDataModel
        The template's data model as a resolver.
    • Constructor Detail

      • TemplateFilter

        public TemplateFilter()
        Constructor.
      • TemplateFilter

        public TemplateFilter​(Context context)
        Constructor.
        Parameters:
        context - The context.
      • TemplateFilter

        public TemplateFilter​(Context context,
                              Restlet next)
        Constructor.
        Parameters:
        context - The context.
        next - The next Restlet.
      • TemplateFilter

        public TemplateFilter​(Context context,
                              Restlet next,
                              java.util.Map<java.lang.String,​java.lang.Object> dataModel)
        Constructor.
        Parameters:
        context - The context.
        next - The next Restlet.
        dataModel - The filter's data model.
      • TemplateFilter

        public TemplateFilter​(Context context,
                              Restlet next,
                              Resolver<java.lang.Object> dataModel)
        Constructor.
        Parameters:
        context - The context.
        next - The next Restlet.
        dataModel - The filter's data model.
    • Method Detail

      • afterHandle

        protected void afterHandle​(Request request,
                                   Response response)
        Description copied from class: Filter
        Allows filtering after processing by the next Restlet. Does nothing by default.
        Overrides:
        afterHandle in class Filter
        Parameters:
        request - The request to handle.
        response - The response to update.