Class FileTypeResolver

Utility class that can figure out mime-types and icons related to files. Note that the icons are associated purely to mime-types, so a file may not have a custom icon accessible with this class.

Synopsis

Since

3.0

Inheritance Path.  java.lang.Object-> com.itmill.toolkit.service.FileTypeResolver

DEFAULT_ICON

Default icon given if no icon is specified for a mime-type.

DEFAULT_MIME_TYPE

Default mime-type.

addExtension(String, String)

Parameters

extension

the filename extension to be associated with MIMEType

MIMEType

the new mime-type for extension

Adds a mime-type mapping for the given filename extension. If the extension is already in the internal mapping it is overwritten.

addIcon(String, Resource)

Parameters

MIMEType

the mime-type whose icon is to be changed

icon

the new icon to be associated with MIMEType

Adds a icon for the given mime-type. If the mime-type also has a corresponding icon, it is replaced with the new icon.

getExtensionToMIMETypeMapping()

Parameters

return

unmodifiable map containing the current file extension to mime-type mapping

Gets the internal file extension to mime-type mapping.

getIcon(File)

Parameters

file

the file whose icon is requested

return

the icon corresponding to the given file

Gets the descriptive icon representing a file. First the mime-type for the given file name is resolved, and then the corresponding icon is fetched from the internal icon storage. If it is not found the default icon is returned.

getIcon(String)

Parameters

fileName

name of the file whose icon is requested

return

the icon corresponding to the given file

Gets the descriptive icon representing file, based on the filename. First the mime-type for the given filename is resolved, and then the corresponding icon is fetched from the internal icon storage. If it is not found the default icon is returned.

getMIMEType(File)

Parameters

file

the file whose mime-type is requested

return

the files mime-type String

Gets the mime-type for a file. Currently the returned file type is resolved by the filename extension only.

getMIMEType(String)

Parameters

fileName

name of the file whose mime-type is requested

return

mime-type String for the given filename

Gets the mime-type of a file. Currently the mime-type is resolved based only on the file name extension.

getMIMETypeToIconMapping()

Parameters

return

unmodifiable map containing the current mime-type to icon mapping

Gets the internal mime-type to icon mapping.