@ThreadSafe public final class MimeTypeDeterminator extends Object
| Modifier and Type | Field and Description |
|---|---|
static IMimeType |
DEFAULT_MIME_TYPE |
| Modifier and Type | Method and Description |
|---|---|
static Map<String,String> |
getAllKnownMimeTypeFilenameMappings() |
static Collection<String> |
getAllKnownMimeTypes() |
static List<MimeTypeContent> |
getAllMimeTypeContents() |
static IMimeType |
getMimeTypeFromBytes(byte[] b)
Try to determine the MIME type from the given byte array.
|
static IMimeType |
getMimeTypeFromBytes(byte[] b,
IMimeType aDefault)
Try to determine the MIME type from the given byte array.
|
static String |
getMimeTypeFromExtension(String sExtension)
Get the MIME type from the passed filename extension.
|
static String |
getMimeTypeFromFilename(String sFilename)
Get the MIME type from the extension of the passed filename.
|
static IMimeType |
getMimeTypeFromString(String s,
Charset aCharset)
Try to find the MIME type that matches the passed content string.
|
static IMimeType |
getMimeTypeFromString(String s,
Charset aCharset,
IMimeType aDefault)
Try to find the MIME type that matches the passed content string.
|
static IMimeType |
getMimeTypeFromString(String s,
String sCharsetName)
Deprecated.
|
static MimeType |
getMimeTypeObjectFromExtension(String sExtension)
Get the MIME type object from the passed filename extension.
|
static MimeType |
getMimeTypeObjectFromFilename(String sFilename)
Get the MIME type object from the extension of the passed filename.
|
static EChange |
registerMimeTypeContent(MimeTypeContent aMimeTypeContent)
Register a new MIME content type.
|
static void |
resetCache()
Reset the MimeTypeContent cache to the initial state.
|
static EChange |
unregisterMimeTypeContent(MimeTypeContent aMimeTypeContent)
Unregister an existing MIME content type.
|
public static final IMimeType DEFAULT_MIME_TYPE
@Nonnull public static EChange registerMimeTypeContent(@Nonnull MimeTypeContent aMimeTypeContent)
aMimeTypeContent - The content type to register. May not be null.EChange.CHANGED if the object was successfully registered.@Nonnull public static EChange unregisterMimeTypeContent(@Nullable MimeTypeContent aMimeTypeContent)
aMimeTypeContent - The content type to unregister. May not be null.EChange.CHANGED if the object was successfully
unregistered.@Nonnull @Deprecated public static IMimeType getMimeTypeFromString(@Nullable String s, @Nonnull@Nonempty String sCharsetName)
s - The content string to check. May be null.sCharsetName - The charset used to convert the string to a byte array. May neither
be null nor empty.null if no matching MIME type was found.@Nonnull public static IMimeType getMimeTypeFromString(@Nullable String s, @Nonnull Charset aCharset)
s - The content string to check. May be null.aCharset - The charset used to convert the string to a byte array. May not be
null.DEFAULT_MIME_TYPE if no matching MIME type was found.
Never null.@Nullable public static IMimeType getMimeTypeFromString(@Nullable String s, @Nonnull Charset aCharset, @Nullable IMimeType aDefault)
s - The content string to check. May be null.aCharset - The charset used to convert the string to a byte array. May not be
null.aDefault - The default MIME type to be returned, if no MIME type could be
found. May be null.aDefault if no matching MIME type was found. May be
null.@Nonnull public static IMimeType getMimeTypeFromBytes(@Nullable byte[] b)
b - The byte array to parse. May be null or empty.DEFAULT_MIME_TYPE if no specific MIME type was found.
Never null.@Nullable public static IMimeType getMimeTypeFromBytes(@Nullable byte[] b, @Nullable IMimeType aDefault)
b - The byte array to parse. May be null or empty.aDefault - The default MIME type to be returned, if no matching MIME type was
found. May be null.null.@Nonnull @ReturnsMutableCopy public static List<MimeTypeContent> getAllMimeTypeContents()
MimeTypeContent objects. Never
null but maybe empty.@Nullable public static String getMimeTypeFromFilename(@Nullable String sFilename)
sFilename - The filename to check. May be null.null if no MIME type was found.@Nullable public static MimeType getMimeTypeObjectFromFilename(@Nonnull String sFilename)
sFilename - The filename to check. May be null.null if no MIME type was found.@Nullable public static String getMimeTypeFromExtension(@Nullable String sExtension)
sExtension - The extension to check. Must be without the leading dot, so "doc" is
valid but ".doc" is not. May be null.null if no MIME type was found.@Nullable public static MimeType getMimeTypeObjectFromExtension(@Nullable String sExtension)
sExtension - The extension to check. Must be without the leading dot, so "doc" is
valid but ".doc" is not. May be null.null if no MIME type was found.@Nonnull @ReturnsMutableCopy public static Collection<String> getAllKnownMimeTypes()
null list of all known MIME types as string.@Nonnull @ReturnsMutableCopy public static Map<String,String> getAllKnownMimeTypeFilenameMappings()
null map from filename extension to MIME type.
Never null.public static void resetCache()
Copyright © 2006–2015 phloc systems. All rights reserved.