-
public final class MimeTypeResolver
-
-
Constructor Summary
Constructors Constructor Description MimeTypeResolver(ImmutableConfig conf)
-
Method Summary
Modifier and Type Method Description static StringcleanMimeType(String origType)Cleans a MimeType name by removing out the actual MimeType,from a string of the form: <primary type>/<sub type> ; < optional paramsvoidreload(ImmutableConfig conf)StringautoResolveContentType(String typeName, @NotNull() String url, @Nullable() Array<byte> data)A facade interface to trying all the possible mime type resolutionstrategies available within Tika. StringgetMimeType(String url)Facade interface to Tika's underlying getMimeType method. StringforName(String name)A facade interface to Tika's underlying forName method. StringgetMimeType(File f)Facade interface to Tika's underlying getMimeType method. -
-
Method Detail
-
cleanMimeType
static String cleanMimeType(String origType)
Cleans a MimeType name by removing out the actual MimeType,from a string of the form:
<primary type>/<sub type> ; < optional params- Parameters:
origType- The original mime type string to be cleaned.
-
reload
void reload(ImmutableConfig conf)
-
autoResolveContentType
String autoResolveContentType(String typeName, @NotNull() String url, @Nullable() Array<byte> data)
A facade interface to trying all the possible mime type resolutionstrategies available within Tika. First, the mime type provided in
typeNameis cleaned, with cleanMimeType. Thenthe cleaned mime type is looked up in the underlying Tika MimeTypes registry, by its cleaned name. If the MimeType is found, then thatmime type is used, otherwise URL resolution is used to try and determinethe mime type. However, ifmime.type.magicis enabled in ImmutableConfig, then mime type magic resolution is used to tryand obtain a better-than-the-default approximation of the MimeType.- Parameters:
typeName- The original mime type, returned from a ProtocolOutput.url- The given @see url, that AppConstants was trying to text.data- The byte data, returned from the text, if any.
-
getMimeType
String getMimeType(String url)
Facade interface to Tika's underlying getMimeType method.
- Parameters:
url- A string representation of the document to sense theMimeType for.
-
forName
String forName(String name)
A facade interface to Tika's underlying forName method.
- Parameters:
name- The name of a valid MimeType in the Tika mime registry.
-
getMimeType
String getMimeType(File f)
Facade interface to Tika's underlying getMimeType method.
- Parameters:
f- The File to sense the MimeType for.
-
-
-
-