@ThreadSafe @Singleton public class MimeTypeInfoManager extends Object
MimeTypeInfo objects.| Modifier and Type | Field and Description |
|---|---|
static String |
MIME_TYPE_INFO_XML |
| Constructor and Description |
|---|
MimeTypeInfoManager()
Create a new empty (!!)
|
| Modifier and Type | Method and Description |
|---|---|
void |
addExtension(MimeTypeInfo aInfo,
MimeTypeInfo.ExtensionWithSource aExt) |
void |
addMimeType(MimeTypeInfo aInfo,
MimeTypeInfo.MimeTypeWithSource aMimeType) |
com.helger.commons.state.EChange |
clearCache()
Remove all registered mime types
|
boolean |
containsMimeTypeForExtension(String sExtension)
Check if any mime type is associated with the passed extension
|
boolean |
containsMimeTypeForFilename(String sFilename)
Check if any mime type is registered for the extension of the specified
filename.
|
com.helger.commons.collection.impl.ICommonsOrderedSet<String> |
getAllExtensionsOfMimeType(com.helger.commons.mime.IMimeType aMimeType)
Get all extensions associated to the specified mime type
|
com.helger.commons.collection.impl.ICommonsOrderedSet<String> |
getAllGlobsOfMimeType(com.helger.commons.mime.IMimeType aMimeType)
Get all globs (=filename patterns) associated to the specified mime type
|
com.helger.commons.collection.impl.ICommonsList<MimeTypeInfo> |
getAllInfosOfExtension(String sExtension)
Get all infos associated with the specified filename extension.
|
com.helger.commons.collection.impl.ICommonsList<MimeTypeInfo> |
getAllInfosOfFilename(File aFile) |
com.helger.commons.collection.impl.ICommonsList<MimeTypeInfo> |
getAllInfosOfFilename(String sFilename) |
com.helger.commons.collection.impl.ICommonsList<MimeTypeInfo> |
getAllInfosOfMimeType(com.helger.commons.mime.IMimeType aMimeType)
Get all infos associated with the passed mime type.
|
com.helger.commons.collection.impl.ICommonsList<MimeTypeInfo> |
getAllMimeTypeInfos() |
com.helger.commons.collection.impl.ICommonsOrderedSet<com.helger.commons.mime.IMimeType> |
getAllMimeTypes() |
com.helger.commons.collection.impl.ICommonsOrderedSet<com.helger.commons.mime.IMimeType> |
getAllMimeTypesForExtension(String sExtension)
Get all mime types that are associated to the specified filename extension.
|
com.helger.commons.collection.impl.ICommonsSet<com.helger.commons.mime.IMimeType> |
getAllMimeTypesForFilename(String sFilename)
Get all mime types that are associated to the extension of the specified
filename.
|
com.helger.commons.collection.impl.ICommonsOrderedSet<String> |
getAllMimeTypeStrings() |
com.helger.commons.collection.impl.ICommonsOrderedSet<String> |
getAllMimeTypeStringsForExtension(String sExtension)
Get all mime types that are associated to the specified filename extension.
|
com.helger.commons.collection.impl.ICommonsSet<String> |
getAllMimeTypeStringsForFilename(String sFilename)
Get all mime types that are associated to the extension of the specified
filename.
|
IMicroDocument |
getAsDocument() |
static MimeTypeInfoManager |
getDefaultInstance() |
String |
getPrimaryExtensionOfMimeType(com.helger.commons.mime.IMimeType aMimeType)
Get the primary (=first) extension for the specified mime type.
|
com.helger.commons.mime.IMimeType |
getPrimaryMimeTypeForExtension(String sExtension)
Get the primary (=first) mime type that is associated to the specified
filename extension.
|
com.helger.commons.mime.IMimeType |
getPrimaryMimeTypeForFilename(String sFilename)
Get the primary (=first) mime type associated with the specified filename.
|
String |
getPrimaryMimeTypeStringForExtension(String sExtension)
Get the primary (=first) mime type that is associated to the specified
filename extension.
|
String |
getPrimaryMimeTypeStringForFilename(String sFilename)
Get the primary (=first) mime type associated with the specified filename.
|
static boolean |
isDefaultInstantiated() |
MimeTypeInfoManager |
read(com.helger.commons.io.resource.IReadableResource aRes)
Read the information from the specified resource.
|
MimeTypeInfoManager |
readDefault()
Read the default resource.
|
void |
registerMimeType(MimeTypeInfo aInfo) |
void |
reinitializeToDefault() |
public static final String MIME_TYPE_INFO_XML
public MimeTypeInfoManager()
public static boolean isDefaultInstantiated()
@Nonnull public static MimeTypeInfoManager getDefaultInstance()
MimeTypeInfos.@Nonnull public MimeTypeInfoManager readDefault()
MIME_TYPE_INFO_XML@Nonnull public MimeTypeInfoManager read(@Nonnull com.helger.commons.io.resource.IReadableResource aRes)
aRes - The resource to read. May not be null.@Nonnull public com.helger.commons.state.EChange clearCache()
EChange.public void reinitializeToDefault()
@Nonnull @ReturnsMutableCopy public IMicroDocument getAsDocument()
public void registerMimeType(@Nonnull MimeTypeInfo aInfo)
@VisibleForTesting public final void addExtension(@Nonnull MimeTypeInfo aInfo, @Nonnull MimeTypeInfo.ExtensionWithSource aExt)
@VisibleForTesting public final void addMimeType(@Nonnull MimeTypeInfo aInfo, @Nonnull MimeTypeInfo.MimeTypeWithSource aMimeType)
@Nullable @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsList<MimeTypeInfo> getAllInfosOfFilename(@Nullable File aFile)
@Nullable @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsList<MimeTypeInfo> getAllInfosOfFilename(@Nullable String sFilename)
@Nullable @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsList<MimeTypeInfo> getAllInfosOfExtension(@Nullable String sExtension)
sExtension - The extension to search. May be null or empty.null if the passed extension is null or
if no such extension is registered.@Nullable @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsList<MimeTypeInfo> getAllInfosOfMimeType(@Nullable com.helger.commons.mime.IMimeType aMimeType)
aMimeType - The mime type to search. May be null.null if a null mime type was passed or
the passed mime type is unknown.@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsList<MimeTypeInfo> getAllMimeTypeInfos()
null set with all mime types infos known to this
instance.@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsOrderedSet<com.helger.commons.mime.IMimeType> getAllMimeTypes()
null set with all mime types known to this
instance.@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsOrderedSet<String> getAllMimeTypeStrings()
null set with all mime types known to this
instance.public boolean containsMimeTypeForFilename(@Nonnull @Nonempty String sFilename)
sFilename - The filename to search. May neither be null nor empty.true if at least one mime type is associated with the
extension of the passed filename, false otherwise.@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsSet<com.helger.commons.mime.IMimeType> getAllMimeTypesForFilename(@Nonnull @Nonempty String sFilename)
sFilename - The filename to search. May neither be null nor empty.null but maybe empty set if no mime type is
associated with the extension of the passed filename.@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsSet<String> getAllMimeTypeStringsForFilename(@Nonnull @Nonempty String sFilename)
sFilename - The filename to search. May neither be null nor empty.null but maybe empty set if no mime type is
associated with the extension of the passed filename.@Nullable public com.helger.commons.mime.IMimeType getPrimaryMimeTypeForFilename(@Nonnull @Nonempty String sFilename)
sFilename - The filename to retrieve the primary mime type from. May neither be
null nor empty.null if no mime type is associated with the extension
of the passed filename@Nullable public String getPrimaryMimeTypeStringForFilename(@Nonnull @Nonempty String sFilename)
sFilename - The filename to retrieve the primary mime type from. May neither be
null nor empty.null if no mime type is associated with the extension
of the passed filenamepublic boolean containsMimeTypeForExtension(@Nonnull String sExtension)
sExtension - The filename extension to search. May not be null.true if at least one mime type is associated,
false if no mime type is associated with the extension@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsOrderedSet<com.helger.commons.mime.IMimeType> getAllMimeTypesForExtension(@Nonnull String sExtension)
sExtension - The filename extension to search. May not be null.null but maybe empty set if no mime type is
associated with the passed extension.@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsOrderedSet<String> getAllMimeTypeStringsForExtension(@Nonnull String sExtension)
sExtension - The filename extension to search. May not be null.null but maybe empty set if no mime type is
associated with the passed extension.@Nullable public com.helger.commons.mime.IMimeType getPrimaryMimeTypeForExtension(@Nonnull String sExtension)
sExtension - The filename extension to search. May not be null.null if no mime type is associated with the passed
extension.@Nullable public String getPrimaryMimeTypeStringForExtension(@Nonnull String sExtension)
sExtension - The filename extension to search. May not be null.null if no mime type is associated with the passed
extension.@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsOrderedSet<String> getAllExtensionsOfMimeType(@Nullable com.helger.commons.mime.IMimeType aMimeType)
aMimeType - The mime type to search. May be null.null but empty set if no extensions are present.@Nullable public String getPrimaryExtensionOfMimeType(@Nullable com.helger.commons.mime.IMimeType aMimeType)
aMimeType - The mime type to be searched. May be null.null if the mime type has no file extension assigned@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsOrderedSet<String> getAllGlobsOfMimeType(@Nullable com.helger.commons.mime.IMimeType aMimeType)
aMimeType - The mime type to search. May be null.null but empty set if no globs are present.Copyright © 2014–2023 Philip Helger. All rights reserved.