Class BaseDataResource<T>

    • Constructor Detail

      • BaseDataResource

        public BaseDataResource​(String contentType,
                                T data)
        Creates a Resource from the given data with its content type
        Parameters:
        contentType - The Content type of the array.
        data - The data
      • BaseDataResource

        public BaseDataResource​(String contentType,
                                T data,
                                String filename)
        Creates a Resource from the given data with its content type and filename
        Parameters:
        contentType - The Content type of the array.
        data - The data
        filename - The filename that will be set as the Content-Disposition header.
    • Method Detail

      • configureResponse

        protected void configureResponse​(AbstractResource.ResourceResponse response,
                                         IResource.Attributes attributes)
        Post-configures the given response, e.g. set/override response headers.
        Parameters:
        response - The response to configure
        attributes - The request attributes (web request, web response, parameters)
      • writeData

        protected abstract void writeData​(org.apache.wicket.request.Response response,
                                          T data)
        Writes the given data to the response
        Parameters:
        response - The response to write to
        data - The data to write
      • getLength

        protected abstract Long getLength​(T data)
        Parameters:
        data - The data to be written
        Returns:
        The length of the data to be written. Used to set "Content-Length" response header
      • getData

        protected T getData​(IResource.Attributes attributes)
        Gets the data for this resource.
        Parameters:
        attributes - the context bringing the request, response and the parameters
        Returns:
        The data for this resource
      • getFilename

        protected String getFilename()
        Returns the filename that will be set as the Content-Disposition header.
        Returns:
        the filename