Package com.helger.xml.util.mime
Class MimeTypeInfoManager
java.lang.Object
com.helger.xml.util.mime.MimeTypeInfoManager
This is the central manager for all
MimeTypeInfo objects.- Author:
- Philip Helger
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal voidaddExtension(MimeTypeInfo aInfo, MimeTypeInfo.ExtensionWithSource aExt) final voidaddMimeType(MimeTypeInfo aInfo, MimeTypeInfo.MimeTypeWithSource aMimeType) com.helger.commons.state.EChangeRemove all registered mime typesbooleancontainsMimeTypeForExtension(String sExtension) Check if any mime type is associated with the passed extensionbooleancontainsMimeTypeForFilename(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 typecom.helger.commons.collection.impl.ICommonsOrderedSet<String> getAllGlobsOfMimeType(com.helger.commons.mime.IMimeType aMimeType) Get all globs (=filename patterns) associated to the specified mime typecom.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> com.helger.commons.collection.impl.ICommonsOrderedSet<com.helger.commons.mime.IMimeType> 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> 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.static MimeTypeInfoManagergetPrimaryExtensionOfMimeType(com.helger.commons.mime.IMimeType aMimeType) Get the primary (=first) extension for the specified mime type.com.helger.commons.mime.IMimeTypegetPrimaryMimeTypeForExtension(String sExtension) Get the primary (=first) mime type that is associated to the specified filename extension.com.helger.commons.mime.IMimeTypegetPrimaryMimeTypeForFilename(String sFilename) Get the primary (=first) mime type associated with the specified filename.getPrimaryMimeTypeStringForExtension(String sExtension) Get the primary (=first) mime type that is associated to the specified filename extension.getPrimaryMimeTypeStringForFilename(String sFilename) Get the primary (=first) mime type associated with the specified filename.static booleanread(com.helger.commons.io.resource.IReadableResource aRes) Read the information from the specified resource.Read the default resource.voidregisterMimeType(MimeTypeInfo aInfo) void
-
Field Details
-
MIME_TYPE_INFO_XML
- See Also:
-
-
Constructor Details
-
MimeTypeInfoManager
public MimeTypeInfoManager()Create a new empty (!!) instance.
-
-
Method Details
-
isDefaultInstantiated
public static boolean isDefaultInstantiated() -
getDefaultInstance
- Returns:
- The default instance that contains all predefined
MimeTypeInfos.
-
readDefault
Read the default resource.- Returns:
- this
- See Also:
-
read
@Nonnull public MimeTypeInfoManager read(@Nonnull com.helger.commons.io.resource.IReadableResource aRes) Read the information from the specified resource.- Parameters:
aRes- The resource to read. May not benull.- Returns:
- this
-
clearCache
Remove all registered mime types- Returns:
EChange.
-
reinitializeToDefault
public void reinitializeToDefault() -
getAsDocument
-
registerMimeType
-
addExtension
@VisibleForTesting public final void addExtension(@Nonnull MimeTypeInfo aInfo, @Nonnull MimeTypeInfo.ExtensionWithSource aExt) -
addMimeType
@VisibleForTesting public final void addMimeType(@Nonnull MimeTypeInfo aInfo, @Nonnull MimeTypeInfo.MimeTypeWithSource aMimeType) -
getAllInfosOfFilename
@Nullable @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsList<MimeTypeInfo> getAllInfosOfFilename(@Nullable File aFile) -
getAllInfosOfFilename
@Nullable @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsList<MimeTypeInfo> getAllInfosOfFilename(@Nullable String sFilename) -
getAllInfosOfExtension
@Nullable @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsList<MimeTypeInfo> getAllInfosOfExtension(@Nullable String sExtension) Get all infos associated with the specified filename extension.- Parameters:
sExtension- The extension to search. May benullor empty.- Returns:
nullif the passed extension isnullor if no such extension is registered.
-
getAllInfosOfMimeType
@Nullable @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsList<MimeTypeInfo> getAllInfosOfMimeType(@Nullable com.helger.commons.mime.IMimeType aMimeType) Get all infos associated with the passed mime type.- Parameters:
aMimeType- The mime type to search. May benull.- Returns:
nullif anullmime type was passed or the passed mime type is unknown.
-
getAllMimeTypeInfos
@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsList<MimeTypeInfo> getAllMimeTypeInfos()- Returns:
- A non-
nullset with all mime types infos known to this instance.
-
getAllMimeTypes
@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsOrderedSet<com.helger.commons.mime.IMimeType> getAllMimeTypes()- Returns:
- A non-
nullset with all mime types known to this instance.
-
getAllMimeTypeStrings
@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsOrderedSet<String> getAllMimeTypeStrings()- Returns:
- A non-
nullset with all mime types known to this instance.
-
containsMimeTypeForFilename
Check if any mime type is registered for the extension of the specified filename.- Parameters:
sFilename- The filename to search. May neither benullnor empty.- Returns:
trueif at least one mime type is associated with the extension of the passed filename,falseotherwise.
-
getAllMimeTypesForFilename
@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsSet<com.helger.commons.mime.IMimeType> getAllMimeTypesForFilename(@Nonnull @Nonempty String sFilename) Get all mime types that are associated to the extension of the specified filename.- Parameters:
sFilename- The filename to search. May neither benullnor empty.- Returns:
- Never
nullbut maybe empty set if no mime type is associated with the extension of the passed filename.
-
getAllMimeTypeStringsForFilename
@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsSet<String> getAllMimeTypeStringsForFilename(@Nonnull @Nonempty String sFilename) Get all mime types that are associated to the extension of the specified filename.- Parameters:
sFilename- The filename to search. May neither benullnor empty.- Returns:
- Never
nullbut maybe empty set if no mime type is associated with the extension of the passed filename.
-
getPrimaryMimeTypeForFilename
@Nullable public com.helger.commons.mime.IMimeType getPrimaryMimeTypeForFilename(@Nonnull @Nonempty String sFilename) Get the primary (=first) mime type associated with the specified filename.- Parameters:
sFilename- The filename to retrieve the primary mime type from. May neither benullnor empty.- Returns:
nullif no mime type is associated with the extension of the passed filename
-
getPrimaryMimeTypeStringForFilename
Get the primary (=first) mime type associated with the specified filename.- Parameters:
sFilename- The filename to retrieve the primary mime type from. May neither benullnor empty.- Returns:
nullif no mime type is associated with the extension of the passed filename
-
containsMimeTypeForExtension
Check if any mime type is associated with the passed extension- Parameters:
sExtension- The filename extension to search. May not benull.- Returns:
trueif at least one mime type is associated,falseif no mime type is associated with the extension
-
getAllMimeTypesForExtension
@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsOrderedSet<com.helger.commons.mime.IMimeType> getAllMimeTypesForExtension(@Nonnull String sExtension) Get all mime types that are associated to the specified filename extension.- Parameters:
sExtension- The filename extension to search. May not benull.- Returns:
- Never
nullbut maybe empty set if no mime type is associated with the passed extension.
-
getAllMimeTypeStringsForExtension
@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsOrderedSet<String> getAllMimeTypeStringsForExtension(@Nonnull String sExtension) Get all mime types that are associated to the specified filename extension.- Parameters:
sExtension- The filename extension to search. May not benull.- Returns:
- Never
nullbut maybe empty set if no mime type is associated with the passed extension.
-
getPrimaryMimeTypeForExtension
@Nullable public com.helger.commons.mime.IMimeType getPrimaryMimeTypeForExtension(@Nonnull String sExtension) Get the primary (=first) mime type that is associated to the specified filename extension.- Parameters:
sExtension- The filename extension to search. May not benull.- Returns:
nullif no mime type is associated with the passed extension.
-
getPrimaryMimeTypeStringForExtension
Get the primary (=first) mime type that is associated to the specified filename extension.- Parameters:
sExtension- The filename extension to search. May not benull.- Returns:
nullif no mime type is associated with the passed extension.
-
getAllExtensionsOfMimeType
@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsOrderedSet<String> getAllExtensionsOfMimeType(@Nullable com.helger.commons.mime.IMimeType aMimeType) Get all extensions associated to the specified mime type- Parameters:
aMimeType- The mime type to search. May benull.- Returns:
- Never
nullbut empty set if no extensions are present.
-
getPrimaryExtensionOfMimeType
@Nullable public String getPrimaryExtensionOfMimeType(@Nullable com.helger.commons.mime.IMimeType aMimeType) Get the primary (=first) extension for the specified mime type.- Parameters:
aMimeType- The mime type to be searched. May benull.- Returns:
nullif the mime type has no file extension assigned
-
getAllGlobsOfMimeType
@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsOrderedSet<String> getAllGlobsOfMimeType(@Nullable com.helger.commons.mime.IMimeType aMimeType) Get all globs (=filename patterns) associated to the specified mime type- Parameters:
aMimeType- The mime type to search. May benull.- Returns:
- Never
nullbut empty set if no globs are present.
-