Package net.officefloor.web.resource.spi
Interface ResourceTransformerContext
-
public interface ResourceTransformerContext
Context for theResourceTransformer
.- Author:
- Daniel Sagenschneider
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.nio.file.Path
createFile()
Creates a new file.java.nio.charset.Charset
getCharset()
Obtains theCharset
for the resource.java.lang.String
getContentEncoding()
Obtains theContent-Encoding
of the resource.java.lang.String
getContentType()
Obtains theContent-Type
of the resource.java.lang.String
getPath()
Obtains the path identifying the resource.java.nio.file.Path
getResource()
Obtains thePath
to the resource being transformed.void
setContentEncoding(HttpHeaderValue contentEncoding)
Specifies theContent-Encoding
for the transformed resource.void
setContentType(HttpHeaderValue contentType, java.nio.charset.Charset charset)
Allows specifying a newContent-Type
for the transformed resource.void
setTransformedResource(java.nio.file.Path resource)
Specifies thePath
to the transformed resource.
-
-
-
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 thePath
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 theContent-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 backingResourceSystem
. However, it may be changed by a previousResourceTransformer
.- Returns:
Charset
for the resource.
-
setContentType
void setContentType(HttpHeaderValue contentType, java.nio.charset.Charset charset)
Allows specifying a newContent-Type
for the transformed resource.- Parameters:
contentType
-Content-Type
for the transformed resource. This needs to include theCharset
parameter if required.charset
-Charset
for theHttpFile
. May benull
to use/reset to the defaultCharset
of theResourceSystem
.
-
getContentEncoding
java.lang.String getContentEncoding()
Obtains theContent-Encoding
of the resource.- Returns:
Content-Encoding
of the resource. May benull
if resource not yet encoded.
-
setContentEncoding
void setContentEncoding(HttpHeaderValue contentEncoding) throws java.io.IOException
Specifies theContent-Encoding
for the transformed resource.- Parameters:
contentEncoding
-Content-Encoding
for the transformed resource.- Throws:
java.io.IOException
- IfContent-Encoding
already specified by anotherResourceTransformer
.- 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.
-
-