Module io.helidon.common.media.type
Package io.helidon.common.media.type.spi
Interface MediaTypeDetector
-
public interface MediaTypeDetectorDetect 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
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Optional<String>detectExtensionType(String fileSuffix)Detect media type from a file suffix.default Optional<String>detectType(String fileString)Detect type based on a file string.default Optional<String>detectType(URI uri)Detect type based on aURL.default Optional<String>detectType(URL url)Detect type based on aURL.default Optional<String>detectType(Path file)Detect type based on aPath.
-
-
-
Method Detail
-
detectType
default Optional<String> detectType(URL url)
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
default Optional<String> detectType(URI uri)
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
default Optional<String> detectType(Path file)
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
default Optional<String> detectType(String fileString)
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
Optional<String> detectExtensionType(String fileSuffix)
Detect media type from a file suffix.Example: If the suffix is
txt, this method should returntext/plainif this detector cares about text files.- Parameters:
fileSuffix- suffix (extension) of a file, without the leading dot- Returns:
- media type if detected
-
-