Project Wonder 5.0

er.attachment.utils
Class ERMimeTypeManager

java.lang.Object
  extended by er.attachment.utils.ERMimeTypeManager

public class ERMimeTypeManager
extends java.lang.Object

ERMimeTypeManager provides an interface to looking up mime type metadata.

Author:
mschrag
Properties
er.attachment.mimeTypeser.attachment.mimeTypes
           
er.attachment.additionalMimeTypeser.attachment.additionalMimeTypes
           
er.attachment.mimeType.[mimeType].nameer.attachment.mimeType.[mimeType].name
           
er.attachment.mimeType.[mimeType].utier.attachment.mimeType.[mimeType].uti
           
er.attachment.mimeType.[mimeType].extensionser.attachment.mimeType.[mimeType].extensions
           

Method Summary
 void addMimeType(ERMimeType mimeType)
          Adds a mime type definition to the manager.
 void clearMimeTypes()
          Removes all the mime types from this manager.
 java.lang.String extensionForFileName(java.lang.String fileName)
          Returns the extension for the given filename.
 ERMimeType mimeTypeForExtension(java.lang.String extension, boolean exceptionIfNotFound)
          Returns the ERMimeType for the given file extension, optionally throwing an exception if the type isn't found.
 ERMimeType mimeTypeForFile(java.io.File file, boolean exceptionIfNotFound)
          Returns the ERMimeType for the given file, optionally throwing an exception if the type isn't found.
 ERMimeType mimeTypeForFileName(java.lang.String fileName, boolean exceptionIfNotFound)
          Returns the ERMimeType for the given file name, optionally throwing an exception if the type isn't found.
 ERMimeType mimeTypeForMimeTypeString(java.lang.String mimeType, boolean exceptionIfNotFound)
          Returns the ERMimeType for the given mime type string, optionally throwing an exception if the type isn't found.
 ERMimeType mimeTypeForUTI(java.lang.String uti, boolean exceptionIfNotFound)
          Returns the ERMimeType for the given UTI, optionally throwing an exception if the type isn't found.
static ERMimeTypeManager mimeTypeManager()
          Returns the singleton mime type manager.
static java.lang.String primaryExtension(java.lang.String mimeTypeStr)
          Returns the primary extension for the given mime type.
 void removeMimeType(ERMimeType mimeType)
          Removes the given mime type definition from this manager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

mimeTypeManager

public static ERMimeTypeManager mimeTypeManager()
Returns the singleton mime type manager. See the top level documentation on information about configuring custom mime types.

Returns:
the singleton mime type manager

primaryExtension

public static java.lang.String primaryExtension(java.lang.String mimeTypeStr)
Returns the primary extension for the given mime type.

Parameters:
mimeTypeStr - the mime type string to lookup
Returns:
the primary extension or null if there is no mime type in the system that matches

clearMimeTypes

public void clearMimeTypes()
Removes all the mime types from this manager.


removeMimeType

public void removeMimeType(ERMimeType mimeType)
Removes the given mime type definition from this manager.

Parameters:
mimeType - the mime type to remove

addMimeType

public void addMimeType(ERMimeType mimeType)
Adds a mime type definition to the manager.

Parameters:
mimeType - the mime type to add

extensionForFileName

public java.lang.String extensionForFileName(java.lang.String fileName)
Returns the extension for the given filename.

Parameters:
fileName - the filename
Returns:
the extension of the filename (or null)

mimeTypeForFileName

public ERMimeType mimeTypeForFileName(java.lang.String fileName,
                                      boolean exceptionIfNotFound)
Returns the ERMimeType for the given file name, optionally throwing an exception if the type isn't found.

Parameters:
fileName - the file name to lookup
exceptionIfNotFound - if true, a NoSuchElementException exception is thrown if the mime type isn't found
Returns:
the matching ERMimeType

mimeTypeForFile

public ERMimeType mimeTypeForFile(java.io.File file,
                                  boolean exceptionIfNotFound)
Returns the ERMimeType for the given file, optionally throwing an exception if the type isn't found.

Parameters:
file - the file to lookup
exceptionIfNotFound - if true, a NoSuchElementException exception is thrown if the mime type isn't found
Returns:
the matching ERMimeType

mimeTypeForMimeTypeString

public ERMimeType mimeTypeForMimeTypeString(java.lang.String mimeType,
                                            boolean exceptionIfNotFound)
Returns the ERMimeType for the given mime type string, optionally throwing an exception if the type isn't found.

Parameters:
mimeType - the mime type string to lookup
exceptionIfNotFound - if true, a NoSuchElementException exception is thrown if the mime type isn't found
Returns:
the matching ERMimeType

mimeTypeForExtension

public ERMimeType mimeTypeForExtension(java.lang.String extension,
                                       boolean exceptionIfNotFound)
Returns the ERMimeType for the given file extension, optionally throwing an exception if the type isn't found.

Parameters:
extension - the file extension to lookup
exceptionIfNotFound - if true, a NoSuchElementException exception is thrown if the mime type isn't found
Returns:
the matching ERMimeType

mimeTypeForUTI

public ERMimeType mimeTypeForUTI(java.lang.String uti,
                                 boolean exceptionIfNotFound)
Returns the ERMimeType for the given UTI, optionally throwing an exception if the type isn't found.

Parameters:
uti - the UTI to lookup
exceptionIfNotFound - if true, a NoSuchElementException exception is thrown if the mime type isn't found
Returns:
the matching ERMimeType

Last updated: Tue, Feb 21, 2017 • 05:45 PM CET

Copyright © 2002 – 2007 Project Wonder.