Copyright 2012-02-25 Werner Randelshofer

ch.randelshofer.activation
Class RecognizerFileTypeMap

java.lang.Object
  extended by javax.activation.FileTypeMap
      extended by ch.randelshofer.activation.RecognizerFileTypeMap

public class RecognizerFileTypeMap
extends javax.activation.FileTypeMap

This file data source uses a Recognizer to determine the content type of the file.

Version:
1.1 2002-02-12 Return 'application/octet-stream' when file type can not be determined.
1.0 1999-10-19
Author:
Werner Randelshofer, Hausmatt 10, CH-6405 Immensee, Switzerland.

Constructor Summary
RecognizerFileTypeMap()
          Creates a new instance No Recognizer will be used to determine the content type of the file (#getContentType will always return 'application/octet-stream'.
RecognizerFileTypeMap(Recognizer detector)
          Creates a new instance.
 
Method Summary
 java.lang.String getContentType(java.io.File file)
          Return the base MIME Type of this data.
 java.lang.String getContentType(java.lang.String filename)
          Return the base MIME Type of this data.
 Recognizer getRecognizer()
          Returns the Recognizer that will be used for determining the content type of the file.
 void setRecognizer(Recognizer detector)
          Sets the Recognizer that will be used for determining the content type of the file.
 
Methods inherited from class javax.activation.FileTypeMap
getDefaultFileTypeMap, setDefaultFileTypeMap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RecognizerFileTypeMap

public RecognizerFileTypeMap()
Creates a new instance No Recognizer will be used to determine the content type of the file (#getContentType will always return 'application/octet-stream'.


RecognizerFileTypeMap

public RecognizerFileTypeMap(Recognizer detector)
Creates a new instance. The specified Recognizer will be used to determine the content type of the file.

Method Detail

setRecognizer

public void setRecognizer(Recognizer detector)
Sets the Recognizer that will be used for determining the content type of the file.


getRecognizer

public Recognizer getRecognizer()
Returns the Recognizer that will be used for determining the content type of the file.


getContentType

public java.lang.String getContentType(java.io.File file)
Return the base MIME Type of this data. This method is expected to ALWAYS return a valid (non-null) MIME Type.

Specified by:
getContentType in class javax.activation.FileTypeMap
Returns:
MIME Type or 'application/octet-stream' if content type can not be determined.

getContentType

public java.lang.String getContentType(java.lang.String filename)
Return the base MIME Type of this data. This method is expected to ALWAYS return a valid (non-null) MIME Type.

Specified by:
getContentType in class javax.activation.FileTypeMap
Returns:
MIME Type or 'application/octet-stream' if content type can not be determined.

Copyright 2012-02-25 Werner Randelshofer