Interface ResourceTransformerContext


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

    • getPath

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

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

      Path createFile() throws 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:
      IOException - If fails to create the new file.
    • getContentType

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

      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, 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

      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 IOException
      Specifies the Content-Encoding for the transformed resource.
      Parameters:
      contentEncoding - Content-Encoding for the transformed resource.
      Throws:
      IOException - If Content-Encoding already specified by another ResourceTransformer.
      See Also:
    • setTransformedResource

      void setTransformedResource(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.