Class DecoratingHeaderResponse

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, IHeaderResponse
    Direct Known Subclasses:
    FilteringHeaderResponse, JavaScriptDeferHeaderResponse, ResourceAggregator

    public abstract class DecoratingHeaderResponse
    extends java.lang.Object
    implements IHeaderResponse
    This is simply a helper implementation of IHeaderResponse that really delegates all of its method calls to the IHeaderResponse that is passed into the constructor. It is defined as abstract because it's only meant to be extended and not used a la carte. You can extend it and override only the methods that you want to change the functionality of.
    Author:
    Jeremy Thomerson
    See Also:
    IHeaderResponseDecorator, IHeaderResponse
    • Constructor Summary

      Constructors 
      Constructor Description
      DecoratingHeaderResponse​(IHeaderResponse real)
      Create a header response that simply delegates all methods to the one that is passed in here.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Mark Header rendering is completed and subsequent usage will be ignored.
      protected IHeaderResponse getRealResponse()
      Returns the actual response being decorated for subclasses to be able to pass it off to other objects if they need to do so.
      org.apache.wicket.request.Response getResponse()
      Returns the response that can be used to write arbitrary text to the head section.
      boolean isClosed()  
      void markRendered​(java.lang.Object object)
      Marks the given object as rendered.
      void render​(HeaderItem item)
      Renders the given HeaderItem to the response if none of the tokens of the item has been rendered before.
      boolean wasRendered​(java.lang.Object object)
      Returns whether the given object has been marked as rendered.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DecoratingHeaderResponse

        public DecoratingHeaderResponse​(IHeaderResponse real)
        Create a header response that simply delegates all methods to the one that is passed in here.
        Parameters:
        real - the actual response that this class delegates to by default
    • Method Detail

      • getRealResponse

        protected final IHeaderResponse getRealResponse()
        Returns the actual response being decorated for subclasses to be able to pass it off to other objects if they need to do so.
        Returns:
        the actual wrapped IHeaderResponse
      • markRendered

        public void markRendered​(java.lang.Object object)
        Description copied from interface: IHeaderResponse
        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).
        Specified by:
        markRendered in interface IHeaderResponse
        Parameters:
        object - object to be marked as rendered.
      • wasRendered

        public boolean wasRendered​(java.lang.Object object)
        Description copied from interface: IHeaderResponse
        Returns whether the given object has been marked as rendered.
        • Methods renderJavaScriptReference and renderCSSReference mark the specified ResourceReference as rendered.
        • Method renderJavaScript marks List of two elements (first is javascript body CharSequence and second is id) as rendered.
        • Method renderString marks the whole string as rendered.
        • Method markRendered can be used to mark an arbitrary object as rendered
        Specified by:
        wasRendered in interface IHeaderResponse
        Parameters:
        object - Object that is queried to be rendered
        Returns:
        Whether the object has been marked as rendered during the request
      • getResponse

        public org.apache.wicket.request.Response getResponse()
        Description copied from interface: IHeaderResponse
        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.

        Specified by:
        getResponse in interface IHeaderResponse
        Returns:
        Response
      • close

        public void close()
        Description copied from interface: IHeaderResponse
        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 java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in interface IHeaderResponse
      • isClosed

        public boolean isClosed()
        Specified by:
        isClosed in interface IHeaderResponse
        Returns:
        if header rendering is completed and subsequent usage will be ignored