Module io.helidon.common.media.type
Package io.helidon.common.media.type.spi
Interface MediaTypeDetector
public interface MediaTypeDetector
Detect media type.
Minimal implementation checks result based on file suffix.
If suffix is not sufficient, you can use detectType(String)
, or implement each of the
methods.
-
Method Summary
Modifier and TypeMethodDescriptiondetectExtensionType
(String fileSuffix) Detect media type from a file suffix.detectType
(String fileString) Detect type based on a file string.detectType
(URI uri) Detect type based on aURL
.detectType
(URL url) Detect type based on aURL
.detectType
(Path file) Detect type based on aPath
.
-
Method Details
-
detectType
Detect type based on aURL
. Default implementation uses theURL.getPath()
and invokes thedetectType(String)
.- Parameters:
url
- to find media type from- Returns:
- media type if detected
-
detectType
Detect type based on aURL
. Default implementation uses theURI.getPath()
and invokes thedetectType(String)
.- Parameters:
uri
- to find media type from- Returns:
- media type if detected
-
detectType
Detect type based on aPath
. Default implementation uses thePath.getFileName()
as a String and invokes thedetectType(String)
.- Parameters:
file
- to find media type from- Returns:
- media type if detected
-
detectType
Detect type based on a file string. This may be any string that ends with a file name. Default implementation looks for a suffix (last part of the file string separated by a dot) and if found, invokes thedetectExtensionType(String)
.- Parameters:
fileString
- path, or name of the file to analyze- Returns:
- media type if detected
-
detectExtensionType
Detect media type from a file suffix.Example: If the suffix is
txt
, this method should returntext/plain
if this detector cares about text files.- Parameters:
fileSuffix
- suffix (extension) of a file, without the leading dot- Returns:
- media type if detected
-