Class 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 Detail

      • WindowsRegistryMimeDetector

        public WindowsRegistryMimeDetector()
    • 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 class MimeDetector
        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 class MimeDetector
        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 class MimeDetector
        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 class MimeDetector
        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 class MimeDetector
        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 class MimeDetector
        Parameters:
        in - InputStream.
        Returns:
        Collection of matched MimeType(s)
        Throws:
        java.lang.UnsupportedOperationException