Interface MimetypeService
-
- All Known Implementing Classes:
MimetypeMap
@AlfrescoPublicApi public interface MimetypeServiceThis service interface provides support for Mimetypes.- Author:
- Derek Hulley
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ContentCharsetFindergetContentCharsetFinder()Provides the system default charset finder.java.util.Map<java.lang.String,java.lang.String>getDisplaysByExtension()Get all human readable mimetype descriptions indexed by mimetype extensionjava.util.Map<java.lang.String,java.lang.String>getDisplaysByMimetype()Get all human readable mimetype descriptions indexed by mimetypejava.lang.StringgetExtension(java.lang.String mimetype)Get the extension for the specified mimetypejava.util.Map<java.lang.String,java.lang.String>getExtensionsByMimetype()Get all mimetype extensions indexed by mimetypejava.lang.StringgetMimetype(java.lang.String extension)Get the mimetype for the specified extensionjava.lang.StringgetMimetypeIfNotMatches(ContentReader reader)Use detection heuristics to check if the mime type of the document really matches what it claims to be.java.util.List<java.lang.String>getMimetypes()Get all mimetypesjava.util.Collection<java.lang.String>getMimetypes(java.lang.String extension)Returns a collection of mimetypes ordered by extension.java.util.Map<java.lang.String,java.lang.String>getMimetypesByExtension()Get all mimetypes indexed by extensionjava.lang.StringguessMimetype(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.StringguessMimetype(java.lang.String filename, java.io.InputStream input)Provides a non-null best guess of the appropriate mimetype for a given file.java.lang.StringguessMimetype(java.lang.String filename, ContentReader reader)Provides a non-null best guess of the appropriate mimetype for a given file.booleanisText(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<java.lang.String,java.lang.String> getDisplaysByExtension()
Get all human readable mimetype descriptions indexed by mimetype extension- Returns:
- the map of displays indexed by extension
-
getDisplaysByMimetype
@NotAuditable java.util.Map<java.lang.String,java.lang.String> getDisplaysByMimetype()
Get all human readable mimetype descriptions indexed by mimetype- Returns:
- the map of displays indexed by mimetype
-
getExtensionsByMimetype
@NotAuditable java.util.Map<java.lang.String,java.lang.String> getExtensionsByMimetype()
Get all mimetype extensions indexed by mimetype- Returns:
- the map of extension indexed by mimetype
-
getMimetypesByExtension
@NotAuditable java.util.Map<java.lang.String,java.lang.String> 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<java.lang.String> 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 useguessMimetype(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 extensionreader- 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.
-
guessMimetype
@NotAuditable java.lang.String guessMimetype(java.lang.String filename, java.io.InputStream input)
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 extensioninput- an input stream for the content- 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
-
getMimetypes
@NotAuditable java.util.Collection<java.lang.String> getMimetypes(java.lang.String extension)
Returns a collection of mimetypes ordered by extension.- Parameters:
extension- to restrict the collection to one entry
-
-