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
- thefile
to find a MIME type for- Returns:
- the MIME type or
null
if the MIME type is not recognized - Throws:
IOException
- of an I/O error occursSecurityException
- if the implementation requires an access the file and theFileSystem
denies the operation- Since:
- 19.0
-
findEncoding
For a file containing an encoding information returns the encoding.- Parameters:
file
- thefile
to find an encoding for. It's guaranteed that thefile
has a MIME type supported by the language registering thisTruffleFile.FileTypeDetector
.- Returns:
- the file encoding or
null
if the file does not provide encoding - Throws:
IOException
- of an I/O error occursSecurityException
- if theFileSystem
denies the file access- Since:
- 19.0
-