Class WindowsRegistryMimeDetector
- java.lang.Object
-
- eu.medsea.mimeutil.detector.MimeDetector
-
- eu.medsea.mimeutil.detector.WindowsRegistryMimeDetector
-
public class WindowsRegistryMimeDetector extends MimeDetector
Get the content type for a file extension as stored in the Windows Registry The extensions are stored at "HKEY_CLASSES_ROOT"This MimeDetector will only operate on Windows machines. On any other platform the methods throw a UnsupportedOperationException (These are swallowed by the MimeUtil class) Therefore, it is perfectly acceptable to register this MimeDetector with MimeUtil and it will only be used on a Windows Platform. On all other platforms it will just be ignored.
To register this MimeDetector use
MimeUtil.registerMimeDetector("eu.medsea.mimeutil.detector.WindowsRegistryMimeDetector");
The Collection returned from the getMimeTypesXXX(...) Methods with contain either a single MimeType or the collection will be empty.
This MimeDetector only performs file extension mapping, so the methods taking an InputStream and byte array throw UnsupportedOperationException
-
-
Constructor Summary
Constructors Constructor Description WindowsRegistryMimeDetector()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getDescription()
Abstract method to be implement by concrete MimeDetector(s).java.util.Collection
getMimeTypesByteArray(byte[] data)
Content detection not supportedjava.util.Collection
getMimeTypesFile(java.io.File file)
Abstract method that must be implemented by concrete MimeDetector(s).java.util.Collection
getMimeTypesFileName(java.lang.String fileName)
Abstract method that must be implemented by concrete MimeDetector(s).java.util.Collection
getMimeTypesInputStream(java.io.InputStream in)
Content detection not supportedjava.util.Collection
getMimeTypesURL(java.net.URL url)
Abstract method that must be implemented by concrete MimeDetector(s).-
Methods inherited from class eu.medsea.mimeutil.detector.MimeDetector
closeStream, delete, getMimeTypes, getMimeTypes, getMimeTypes, getMimeTypes, getMimeTypes, getName, init
-
-
-
-
Method Detail
-
getDescription
public java.lang.String getDescription()
Description copied from class:MimeDetector
Abstract method to be implement by concrete MimeDetector(s).- Specified by:
getDescription
in classMimeDetector
- Returns:
- description of this MimeDetector
-
getMimeTypesFile
public java.util.Collection getMimeTypesFile(java.io.File file) throws java.lang.UnsupportedOperationException
Description copied from class:MimeDetector
Abstract method that must be implemented by concrete MimeDetector(s). This takes a file object and is called by the MimeUtil getMimeTypes(File file) method. If your MimeDetector does not handle file names then either throw an UnsupportedOperationException or return an empty collection.- Specified by:
getMimeTypesFile
in classMimeDetector
- Returns:
- Collection of matched MimeType(s)
- Throws:
java.lang.UnsupportedOperationException
-
getMimeTypesFileName
public java.util.Collection getMimeTypesFileName(java.lang.String fileName) throws java.lang.UnsupportedOperationException
Description copied from class:MimeDetector
Abstract method that must be implemented by concrete MimeDetector(s). This takes a file name and is called by the MimeUtil getMimeTypes(String fileName) getMimeTypes(File file) getMimeTypes(URL url) methods. If your MimeDetector does not handle file names then either throw an UnsupportedOperationException or return an empty collection.- Specified by:
getMimeTypesFileName
in classMimeDetector
- Returns:
- Collection of matched MimeType(s)
- Throws:
java.lang.UnsupportedOperationException
-
getMimeTypesURL
public java.util.Collection getMimeTypesURL(java.net.URL url) throws java.lang.UnsupportedOperationException
Description copied from class:MimeDetector
Abstract method that must be implemented by concrete MimeDetector(s). This takes a URL object and is called by the MimeUtil getMimeTypes(URL url) method. If your MimeDetector does not handle file names then either throw an UnsupportedOperationException or return an empty collection.- Specified by:
getMimeTypesURL
in classMimeDetector
- Returns:
- Collection of matched MimeType(s)
- Throws:
java.lang.UnsupportedOperationException
-
getMimeTypesByteArray
public java.util.Collection getMimeTypesByteArray(byte[] data) throws java.lang.UnsupportedOperationException
Content detection not supported- Specified by:
getMimeTypesByteArray
in classMimeDetector
- Parameters:
data
- byte []. Is a byte array that you want to parse for matching mime types.- Returns:
- Collection of matched MimeType(s)
- Throws:
java.lang.UnsupportedOperationException
-
getMimeTypesInputStream
public java.util.Collection getMimeTypesInputStream(java.io.InputStream in) throws java.lang.UnsupportedOperationException
Content detection not supported- Specified by:
getMimeTypesInputStream
in classMimeDetector
- Parameters:
in
- InputStream.- Returns:
- Collection of matched MimeType(s)
- Throws:
java.lang.UnsupportedOperationException
-
-