|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.norther.tammi.acorn.mime.MimeTypeMap
public class MimeTypeMap
MimeTypeMap maintains a set of mappers defining mappings between MIME types and the corresponding file name extensions. The mappings are defined as lines formed by a MIME type name followed by a list of extensions separated by a whitespace. The definitions can be listed in MIME type files located in user's home directory, Java home directory or the current class jar. In addition, this class maintains static default mappings and constructors support application specific mappings.
| Field Summary | |
|---|---|
static String |
MIMETYPE_RESOURCE
The name for MIME type mapper resources. |
| Constructor Summary | |
|---|---|
MimeTypeMap()
Constructs a new MIME type map with default mappers. |
|
MimeTypeMap(File file)
Contructs a MIME type map read from a file. |
|
MimeTypeMap(InputStream input)
Contructs a MIME type map read from a stream. |
|
MimeTypeMap(String path)
Contructs a MIME type map read from a file path. |
|
| Method Summary | |
|---|---|
String |
getContentType(File file)
Gets the MIME content type for a file as a string. |
String |
getContentType(String path)
Gets the MIME content type for a named file as a string. |
String |
getContentType(String ext,
String def)
Gets the MIME content type for a file name extension as a string. |
String[] |
getContentTypes(String ext)
Gets the MIME content types for a file name extension. |
String |
getDefaultExtension(MimeType mime)
Gets the default file name extension for a MIME type. |
String |
getDefaultExtension(String type)
Gets the default file name extension for a MIME type. |
String[] |
getExtensions(String type)
Gets the file name extensions for a MIME type. |
MimeType |
getMimeType(File file)
Gets the MIME content type for a file. |
MimeType |
getMimeType(String name)
Gets the MIME content type for a named file. |
MimeType |
getMimeType(String ext,
String def)
Gets the MIME content type for a file name extension. |
protected static MimeTypeMapper |
loadPath(String path)
Loads mappings from a file path. |
protected static MimeTypeMapper |
loadResource(String name)
Loads mappings from a resource. |
protected void |
setCommonContentType(String spec)
Sets a base MIME content type mapping to extensions. |
void |
setContentType(String spec)
Sets a MIME content type mapping to extensions. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String MIMETYPE_RESOURCE
| Constructor Detail |
|---|
public MimeTypeMap()
public MimeTypeMap(InputStream input)
throws IOException
input - an input stream.
IOException - for an incorrect stream.
public MimeTypeMap(File file)
throws IOException
file - an input file.
IOException - for an incorrect input file.
public MimeTypeMap(String path)
throws IOException
path - an input file path.
IOException - for an incorrect input file.| Method Detail |
|---|
protected static MimeTypeMapper loadPath(String path)
throws IOException
path - a file path.
IOException - for an incorrect file.protected static MimeTypeMapper loadResource(String name)
name - a resource name.
public void setContentType(String spec)
spec - a MIME type extension specification to set.public String getContentType(File file)
file - the file.
public String getContentType(String path)
path - the file path.
public String getContentType(String ext,
String def)
ext - the file name extension.def - the default type if none is found.
public String[] getContentTypes(String ext)
ext - the file name extension.
public MimeType getMimeType(File file)
file - the file.
public MimeType getMimeType(String name)
name - the name of the file.
public MimeType getMimeType(String ext,
String def)
ext - the file name extension.def - the default type if none is found.
public String getDefaultExtension(String type)
type - the MIME type as a string.
public String getDefaultExtension(MimeType mime)
mime - the MIME type.
public String[] getExtensions(String type)
type - the MIME type as a string.
protected void setCommonContentType(String spec)
spec - a MIME type extension specification to set.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||