Interface ResourceTransformerContext


  • public interface ResourceTransformerContext
    Context for the ResourceTransformer.
    Author:
    Daniel Sagenschneider
    • Method Detail

      • getPath

        java.lang.String getPath()
        Obtains the path identifying the resource.
        Returns:
        Path identifying the resource.
      • getResource

        java.nio.file.Path getResource()
        Obtains the Path to the resource being transformed.
        Returns:
        Path to the resource being transformed.
      • createFile

        java.nio.file.Path createFile()
                               throws java.io.IOException

        Creates a new file.

        All files required for transform should be created via this method. This is to ensure the files are managed.

        Returns:
        Path to the new file.
        Throws:
        java.io.IOException - If fails to create the new file.
      • getContentType

        java.lang.String getContentType()
        Obtains the Content-Type of the resource.
        Returns:
        Content-Type of the resource.
      • getCharset

        java.nio.charset.Charset getCharset()

        Obtains the Charset for the resource.

        Typically this is the Charset of the backing ResourceSystem. However, it may be changed by a previous ResourceTransformer.

        Returns:
        Charset for the resource.
      • setContentType

        void setContentType​(HttpHeaderValue contentType,
                            java.nio.charset.Charset charset)
        Allows specifying a new Content-Type for the transformed resource.
        Parameters:
        contentType - Content-Type for the transformed resource. This needs to include the Charset parameter if required.
        charset - Charset for the HttpFile. May be null to use/reset to the default Charset of the ResourceSystem.
      • getContentEncoding

        java.lang.String getContentEncoding()
        Obtains the Content-Encoding of the resource.
        Returns:
        Content-Encoding of the resource. May be null if resource not yet encoded.
      • setContentEncoding

        void setContentEncoding​(HttpHeaderValue contentEncoding)
                         throws java.io.IOException
        Specifies the Content-Encoding for the transformed resource.
        Parameters:
        contentEncoding - Content-Encoding for the transformed resource.
        Throws:
        java.io.IOException - If Content-Encoding already specified by another ResourceTransformer.
        See Also:
        getContentEncoding()
      • setTransformedResource

        void setTransformedResource​(java.nio.file.Path resource)

        Specifies the Path to the transformed resource.

        This is optional to invoke. Should a transform not be applied, then this should not be invoked.

        Parameters:
        resource - Path to the transformed resource.