public class FileTypeResolver extends Object implements Serializable
Note : The icons are associated purely to mime-types, so a file may not have a custom icon accessible with this class.
Modifier and Type | Field and Description |
---|---|
static Resource |
DEFAULT_ICON
Default icon given if no icon is specified for a mime-type.
|
static String |
DEFAULT_MIME_TYPE
Default mime-type.
|
Constructor and Description |
---|
FileTypeResolver() |
Modifier and Type | Method and Description |
---|---|
static void |
addExtension(String extension,
String MIMEType)
Adds a mime-type mapping for the given filename extension.
|
static void |
addIcon(String MIMEType,
Resource icon)
Adds a icon for the given mime-type.
|
static Map<String,String> |
getExtensionToMIMETypeMapping()
Gets the internal file extension to mime-type mapping.
|
static Resource |
getIcon(File file)
Gets the descriptive icon representing a file.
|
static Resource |
getIcon(String fileName)
Gets the descriptive icon representing file, based on the filename.
|
static String |
getMIMEType(File file)
Gets the mime-type for a file.
|
static String |
getMIMEType(String fileName)
Gets the mime-type of a file.
|
static Map<String,Resource> |
getMIMETypeToIconMapping()
Gets the internal mime-type to icon mapping.
|
public static Resource DEFAULT_ICON
public static String DEFAULT_MIME_TYPE
public static String getMIMEType(String fileName)
fileName
- the name of the file whose mime-type is requested.String
for the given filenamepublic static Resource getIcon(String fileName)
fileName
- the name of the file whose icon is requested.public static Resource getIcon(File file)
file
- the file whose icon is requested.public static String getMIMEType(File file)
file
- the file whose mime-type is requested.String
public static void addExtension(String extension, String MIMEType)
extension
- the filename extension to be associated with
MIMEType
.MIMEType
- the new mime-type for extension
.public static void addIcon(String MIMEType, Resource icon)
MIMEType
- the mime-type whose icon is to be changed.icon
- the new icon to be associated with MIMEType
.public static Map<String,String> getExtensionToMIMETypeMapping()
Copyright © 2016 Vaadin Ltd. All rights reserved.