org.alfresco.service.cmr.repository
Interface MimetypeService

All Known Implementing Classes:
MimetypeMap

public interface MimetypeService

This service interface provides support for Mimetypes.


Method Summary
 ContentCharsetFinder getContentCharsetFinder()
          Provides the system default charset finder.
 java.util.Map getDisplaysByExtension()
          Get all human readable mimetype descriptions indexed by mimetype extension
 java.util.Map getDisplaysByMimetype()
          Get all human readable mimetype descriptions indexed by mimetype
 java.lang.String getExtension(java.lang.String mimetype)
          Get the extension for the specified mimetype
 java.util.Map getExtensionsByMimetype()
          Get all mimetype extensions indexed by mimetype
 java.lang.String getMimetype(java.lang.String extension)
          Get the mimetype for the specified extension
 java.lang.String getMimetypeIfNotMatches(ContentReader reader)
          Use detection heuristics to check if the mime type of the document really matches what it claims to be.
 java.util.List getMimetypes()
          Get all mimetypes
 java.util.Map getMimetypesByExtension()
          Get all mimetypes indexed by extension
 java.lang.String guessMimetype(java.lang.String filename)
          Provides a non-null best guess of the appropriate mimetype given a filename, based entirely on the file extension.
 java.lang.String guessMimetype(java.lang.String filename, ContentReader reader)
          Provides a non-null best guess of the appropriate mimetype for a given file.
 boolean isText(java.lang.String mimetype)
          Check if a given mimetype represents a text format.
 

Method Detail

getExtension

@NotAuditable
java.lang.String getExtension(java.lang.String mimetype)
Get the extension for the specified mimetype

Parameters:
mimetype - a valid mimetype
Returns:
Returns the default extension for the mimetype

getMimetype

@NotAuditable
java.lang.String getMimetype(java.lang.String extension)
Get the mimetype for the specified extension

Parameters:
extension - a valid file extension
Returns:
Returns a valid mimetype if found, or null if does not exist

getDisplaysByExtension

@NotAuditable
java.util.Map getDisplaysByExtension()
Get all human readable mimetype descriptions indexed by mimetype extension

Returns:
the map of displays indexed by extension

getDisplaysByMimetype

@NotAuditable
java.util.Map getDisplaysByMimetype()
Get all human readable mimetype descriptions indexed by mimetype

Returns:
the map of displays indexed by mimetype

getExtensionsByMimetype

@NotAuditable
java.util.Map getExtensionsByMimetype()
Get all mimetype extensions indexed by mimetype

Returns:
the map of extension indexed by mimetype

getMimetypesByExtension

@NotAuditable
java.util.Map getMimetypesByExtension()
Get all mimetypes indexed by extension

Returns:
the map of mimetypes indexed by extension

isText

@NotAuditable
boolean isText(java.lang.String mimetype)
Check if a given mimetype represents a text format.

Parameters:
mimetype - the mimetype to check
Returns:
Returns true if it is text

getMimetypes

@NotAuditable
java.util.List getMimetypes()
Get all mimetypes

Returns:
all mimetypes

guessMimetype

@NotAuditable
java.lang.String guessMimetype(java.lang.String filename)
Provides a non-null best guess of the appropriate mimetype given a filename, based entirely on the file extension. Because file extensions can be wrong, you are strongly advised to use MimetypeService.guessMimetype(String, ContentReader) instead.

Parameters:
filename - the name of the file with an optional file extension
Returns:
Returns the best guess mimetype or the mimetype for straight binary files if no extension could be found.

guessMimetype

@NotAuditable
java.lang.String guessMimetype(java.lang.String filename,
                                            ContentReader reader)
Provides a non-null best guess of the appropriate mimetype for a given file. Uses a mixture of file name and file content logic to identify the mimetype for the file, and will usually manage to identify files with incorrect extensions.

Parameters:
filename - the name of the file with an optional file extension
reader - a reader for the content of the file
Returns:
Returns the best guess mimetype or the mimetype for straight binary files if no extension could be found.

getMimetypeIfNotMatches

@NotAuditable
java.lang.String getMimetypeIfNotMatches(ContentReader reader)
Use detection heuristics to check if the mime type of the document really matches what it claims to be. This is typically used when a transformation or metadata extractions fails, and you want to know if someone has renamed a file and consequently it has the wrong mime type.

Returns:
Null if the mime type seems ok, otherwise the mime type it probably is

getContentCharsetFinder

@NotAuditable
ContentCharsetFinder getContentCharsetFinder()
Provides the system default charset finder.

Returns:
Returns a character set finder that can be used to decode streams in order to get the encoding.
Since:
2.1


Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.