eu.medsea.mimeutil.detector
Class WindowsRegistryMimeDetector

java.lang.Object
  extended by eu.medsea.mimeutil.detector.MimeDetector
      extended by 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

Author:
Steven McArdle

Constructor Summary
WindowsRegistryMimeDetector()
           
 
Method Summary
 String getDescription()
          Abstract method to be implement by concrete MimeDetector(s).
 Collection getMimeTypesByteArray(byte[] data)
          Content detection not supported
 Collection getMimeTypesFile(File file)
          Abstract method that must be implemented by concrete MimeDetector(s).
 Collection getMimeTypesFileName(String fileName)
          Abstract method that must be implemented by concrete MimeDetector(s).
 Collection getMimeTypesInputStream(InputStream in)
          Content detection not supported
 Collection getMimeTypesURL(URL url)
          Abstract method that must be implemented by concrete MimeDetector(s).
static void main(String[] args)
           
 
Methods inherited from class eu.medsea.mimeutil.detector.MimeDetector
closeStream, delete, getMimeTypes, getMimeTypes, getMimeTypes, getMimeTypes, getMimeTypes, getName, init
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WindowsRegistryMimeDetector

public WindowsRegistryMimeDetector()
Method Detail

getDescription

public 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 Collection getMimeTypesFile(File file)
                            throws 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:
UnsupportedOperationException

getMimeTypesFileName

public Collection getMimeTypesFileName(String fileName)
                                throws 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:
UnsupportedOperationException

getMimeTypesURL

public Collection getMimeTypesURL(URL url)
                           throws 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:
UnsupportedOperationException

getMimeTypesByteArray

public Collection getMimeTypesByteArray(byte[] data)
                                 throws 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:
UnsupportedOperationException

getMimeTypesInputStream

public Collection getMimeTypesInputStream(InputStream in)
                                   throws UnsupportedOperationException
Content detection not supported

Specified by:
getMimeTypesInputStream in class MimeDetector
Parameters:
in - InputStream.
Returns:
Collection of matched MimeType(s)
Throws:
UnsupportedOperationException

main

public static void main(String[] args)
                 throws Exception
Throws:
Exception


Copyright © 2007-2009 Medsea Business Solutions S.L.. All Rights Reserved.