@Immutable @Deprecated public class MimeTypeUtil extends Object
This utility class may be instantiated to create a new instance with its own set of mappings. If desired, the default mappings
will be loaded using the current thread's context class loader
, and will be loaded from
the /org/modeshape/mime.types
file located on the classpath. The load(InputStream, Map)
method may be
used to load custom mappings (in the standard format) into a Map
instance, which can then be passed to one of the
constructors.
Modifier and Type | Field and Description |
---|---|
static String |
MIME_TYPE_EXTENSIONS_RESOURCE_PATH
Deprecated.
The default location of the properties file containing the extension patterns to MIME types.
|
Constructor and Description |
---|
MimeTypeUtil()
Deprecated.
Create a default instance of the extension-based MIME type detector.
|
MimeTypeUtil(Map<String,String> extensionsToMimeTypes)
Deprecated.
Create an instance of the extension-based MIME type detector by using the supplied mappings.
|
MimeTypeUtil(Map<String,String> extensionsToMimeTypes,
boolean initWithDefaults)
Deprecated.
Create an instance of the extension-based MIME type detector by using the supplied mappings.
|
Modifier and Type | Method and Description |
---|---|
protected static Map<String,String> |
getDefaultMappings()
Deprecated.
Load the default extensions from
MIME_TYPE_EXTENSIONS_RESOURCE_PATH , which can either be a property file or a
tab-delimited *nix-style MIME types file (common in web servers and libraries). |
static Map<String,String> |
load(InputStream stream,
Map<String,Set<String>> duplicateMimeTypesByExtension)
Deprecated.
Load the extensions from the supplied stream, which may provide the contents in the format of property file or a
tab-delimited *nix-style MIME types file (common in web servers and libraries).
|
String |
mimeTypeOf(File file)
Deprecated.
Returns the MIME-type of the file using its name.
|
String |
mimeTypeOf(String filename)
Deprecated.
Returns the MIME-type of a file given the supplied name.
|
public static final String MIME_TYPE_EXTENSIONS_RESOURCE_PATH
public MimeTypeUtil()
public MimeTypeUtil(Map<String,String> extensionsToMimeTypes)
extensionsToMimeTypes
- the mapping of extension patterns to MIME types, which will override the default mappings; may
be null if the default mappings are to be usedpublic MimeTypeUtil(Map<String,String> extensionsToMimeTypes, boolean initWithDefaults)
extensionsToMimeTypes
- the mapping of extension patterns to MIME types, which will override the default mappings; may
be null if the default mappings are to be usedinitWithDefaults
- true if the default mappings are to be loaded first, or false if the default mappings are not to be
used at allprotected static Map<String,String> getDefaultMappings()
MIME_TYPE_EXTENSIONS_RESOURCE_PATH
, which can either be a property file or a
tab-delimited *nix-style MIME types file (common in web servers and libraries). If an extension applies to more than one
MIME type, the first one in the file wins.public static Map<String,String> load(InputStream stream, Map<String,Set<String>> duplicateMimeTypesByExtension)
stream
- the stream containing the content; may not be nullduplicateMimeTypesByExtension
- a map into which any extension should be placed if there are multiple MIME types that
apply; may be null if this information is not requiredpublic String mimeTypeOf(String filename)
null
is
returned.filename
- the file name; may be null
.null
if the MIME-type could not be determined.public String mimeTypeOf(File file)
null
is returned.file
- the file; may be null
.null
if the MIME-type could not be determined.Copyright © 2008-2014 JBoss, a division of Red Hat. All Rights Reserved.