Interface TruffleFile.FileTypeDetector
- Enclosing class:
TruffleFile
public static interface TruffleFile.FileTypeDetector
A detector for finding
file's MIME type and encoding.
The means by which the detector determines the MIME is highly implementation specific. A
simple implementation might detect the MIME type using file extension. In
other cases, the content of file needs to be examined to guess its file
type.
The implementations are registered using
TruffleLanguage registration.
- Since:
- 19.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionfindEncoding(TruffleFile file) For a file containing an encoding information returns the encoding.findMimeType(TruffleFile file) Finds a MIME type for givenTruffleFile.
-
Method Details
-
findMimeType
Finds a MIME type for givenTruffleFile.- Parameters:
file- thefileto find a MIME type for- Returns:
- the MIME type or
nullif the MIME type is not recognized - Throws:
IOException- of an I/O error occursSecurityException- if the implementation requires an access the file and theFileSystemdenies the operation- Since:
- 19.0
-
findEncoding
For a file containing an encoding information returns the encoding.- Parameters:
file- thefileto find an encoding for. It's guaranteed that thefilehas a MIME type supported by the language registering thisTruffleFile.FileTypeDetector.- Returns:
- the file encoding or
nullif the file does not provide encoding - Throws:
IOException- of an I/O error occursSecurityException- if theFileSystemdenies the file access- Since:
- 19.0
-