org.alembik.util
Class MimeTypesRepository

java.lang.Object
  extended by org.alembik.util.MimeTypesRepository
All Implemented Interfaces:
java.io.Serializable

public class MimeTypesRepository
extends java.lang.Object
implements java.io.Serializable

The dictionary providing bidirectional mapping between file extensions and mime-types. Actual bindings are provided in the two accompanying files:

NOTE: since the relation between the two is not unequivocal, one cannot assume the following condition always be true:

contentType.equals (getContentType (getExtension (contentType)))

Since:
1.0-beta1
See Also:
Serialized Form

Method Summary
 java.lang.String getContentType(java.lang.String extension)
          Finds the content type for the given file extension.
 java.lang.String getExtension(java.lang.String contentType)
          Finds the file extension for the given content type.
static MimeTypesRepository getInstance()
          Return the singleton instance of this component.
static java.lang.Class<? extends Media> getMediaClass(java.lang.String contentType)
          Returns the media class corresponding to the given content type.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static MimeTypesRepository getInstance()
Return the singleton instance of this component.

Returns:
class instance

getExtension

public java.lang.String getExtension(java.lang.String contentType)

Finds the file extension for the given content type.

For example image/gif gets resolved into gif.

Parameters:
contentType - mime-type to be resolved
Returns:
corresponding file extension, if found; otherwise null

getContentType

public java.lang.String getContentType(java.lang.String extension)

Finds the content type for the given file extension.

For example jpg gets resolved into image/jpeg.

Parameters:
extension - to be resolved
Returns:
corresponding mime-type if found; otherwise null

getMediaClass

public static java.lang.Class<? extends Media> getMediaClass(java.lang.String contentType)
Returns the media class corresponding to the given content type.

Parameters:
contentType - mime-type string
Returns:
media class if there is one matching; otherwise null