Interface IHeaderResponse

All Superinterfaces:
AutoCloseable, Closeable
All Known Implementing Classes:
CSPNonceHeaderResponseDecorator, DecoratingHeaderResponse, FilteringHeaderResponse, HeaderResponse, JavaScriptDeferHeaderResponse, JavaScriptFilteredIntoFooterHeaderResponse, ResourceAggregator, SubresourceHeaderResponse

public interface IHeaderResponse extends Closeable
Interface that is used to render header elements (usually javascript and CSS references). Implementation of this interface is responsible for filtering duplicate contributions (so that for example the same javascript is not loaded twice) during the same request.
Author:
Matej Knopp
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Mark Header rendering is completed and subsequent usage will be ignored.
    Returns the response that can be used to write arbitrary text to the head section.
    boolean
     
    void
    Marks the given object as rendered.
    void
    Renders the given HeaderItem to the response if none of its tokens has been rendered before.
    boolean
    Returns whether the given object has been marked as rendered.
  • Method Details

    • render

      void render(HeaderItem item)
      Renders the given HeaderItem to the response if none of its tokens has been rendered before.

      Automatically marks all item's tokens as rendered.

      Parameters:
      item - The item to render.
      See Also:
    • markRendered

      void markRendered(Object object)
      Marks the given object as rendered. The object can be anything (string, resource reference, etc...). The purpose of this function is to allow user to manually keep track of rendered items. This can be useful for items that are expensive to generate (like interpolated text).
      Parameters:
      object - object to be marked as rendered.
    • wasRendered

      boolean wasRendered(Object object)
      Returns whether the given object has been marked as rendered.
      Parameters:
      object - Object that is queried to be rendered
      Returns:
      Whether the object has been marked as rendered during the request
      See Also:
    • getResponse

      Returns the response that can be used to write arbitrary text to the head section.

      Note: This method is kind of dangerous as users are able to write to the output whatever they like.

      Returns:
      Response
    • close

      void close()
      Mark Header rendering is completed and subsequent usage will be ignored. If some kind of buffering is used internally, this action will mark that the contents has to be flushed out.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • isClosed

      boolean isClosed()
      Returns:
      if header rendering is completed and subsequent usage will be ignored