@ThreadSafe @Singleton public final class MimeTypeDeterminator extends Object
| Modifier and Type | Field and Description |
|---|---|
static IMimeType |
DEFAULT_MIME_TYPE |
| Modifier and Type | Method and Description |
|---|---|
ICommonsCollection<MimeTypeContent> |
getAllMimeTypeContents() |
static MimeTypeDeterminator |
getInstance() |
IMimeType |
getMimeTypeFromBytes(byte[] b)
Try to determine the MIME type from the given byte array.
|
IMimeType |
getMimeTypeFromBytes(byte[] aBytes,
IMimeType aDefault)
Try to determine the MIME type from the given byte array.
|
IMimeType |
getMimeTypeFromString(String s,
Charset aCharset)
Try to find the MIME type that matches the passed content string.
|
IMimeType |
getMimeTypeFromString(String s,
Charset aCharset,
IMimeType aDefault)
Try to find the MIME type that matches the passed content string.
|
static boolean |
isInstantiated() |
EChange |
registerMimeTypeContent(MimeTypeContent aMimeTypeContent)
Register a new MIME content type.
|
void |
reinitialize()
Reset the MimeTypeContent cache to the initial state.
|
EChange |
unregisterMimeTypeContent(MimeTypeContent aMimeTypeContent)
Unregister an existing MIME content type.
|
public static final IMimeType DEFAULT_MIME_TYPE
public static boolean isInstantiated()
@Nonnull public static MimeTypeDeterminator getInstance()
@Nonnull public 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 EChange unregisterMimeTypeContent(@Nullable MimeTypeContent aMimeTypeContent)
aMimeTypeContent - The content type to unregister. May not be null.EChange.CHANGED if the object was successfully
unregistered.@Nonnull public 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 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 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 IMimeType getMimeTypeFromBytes(@Nullable byte[] aBytes, @Nullable IMimeType aDefault)
aBytes - 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 ICommonsCollection<MimeTypeContent> getAllMimeTypeContents()
MimeTypeContent objects. Never
null but maybe empty.public void reinitialize()
Copyright © 2014–2022 Philip Helger. All rights reserved.