|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.turbine.services.mimetype.util.MimeTypeMap
This class 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 MimeType |
DEFAULT_MIMETYPE
The default MIME type when nothing else is applicable. |
static java.lang.String |
DEFAULT_TYPE
The default MIME type as a string. |
static java.lang.String |
EXT_CHTML
|
static java.lang.String |
EXT_GIF
|
static java.lang.String |
EXT_HDM
|
static java.lang.String |
EXT_HDML
|
static java.lang.String |
EXT_HTM
|
static java.lang.String |
EXT_HTML
Common MIME type extensions. |
static java.lang.String |
EXT_JPEG
|
static java.lang.String |
EXT_JPG
|
static java.lang.String |
EXT_TEXT
|
static java.lang.String |
EXT_WBMP
|
static java.lang.String |
EXT_WML
|
static java.lang.String |
MIMETYPE_RESOURCE
The name for MIME type mapper resources. |
Constructor Summary | |
MimeTypeMap()
Constructs a new MIME type map with default mappers. |
|
MimeTypeMap(java.io.File file)
Contructs a MIME type map read from a file. |
|
MimeTypeMap(java.io.InputStream input)
Contructs a MIME type map read from a stream. |
|
MimeTypeMap(java.lang.String path)
Contructs a MIME type map read from a file path. |
Method Summary | |
java.lang.String |
getContentType(java.io.File file)
Gets the MIME content type for a file as a string. |
java.lang.String |
getContentType(java.lang.String name)
Gets the MIME content type for a named file as a string. |
java.lang.String |
getContentType(java.lang.String ext,
java.lang.String def)
Gets the MIME content type for a file name extension as a string. |
java.lang.String |
getDefaultExtension(MimeType mime)
Gets the default file name extension for a MIME type. |
java.lang.String |
getDefaultExtension(java.lang.String type)
Gets the default file name extension for a MIME type. |
MimeType |
getMimeContentType(java.io.File file)
Gets the MIME content type for a file. |
MimeType |
getMimeContentType(java.lang.String name)
Gets the MIME content type for a named file. |
MimeType |
getMimeContentType(java.lang.String ext,
java.lang.String def)
Gets the MIME content type for a file name extension. |
protected static MimeTypeMapper |
loadPath(java.lang.String path)
Loads mappings from a file path. |
protected static MimeTypeMapper |
loadResource(java.lang.String name)
Loads mappings from a resource. |
protected void |
setCommonContentType(java.lang.String spec)
Sets a common MIME content type mapping to extensions. |
void |
setContentType(java.lang.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 MimeType DEFAULT_MIMETYPE
public static final java.lang.String DEFAULT_TYPE
public static final java.lang.String MIMETYPE_RESOURCE
public static final java.lang.String EXT_HTML
public static final java.lang.String EXT_HTM
public static final java.lang.String EXT_WML
public static final java.lang.String EXT_HDML
public static final java.lang.String EXT_HDM
public static final java.lang.String EXT_CHTML
public static final java.lang.String EXT_TEXT
public static final java.lang.String EXT_GIF
public static final java.lang.String EXT_JPEG
public static final java.lang.String EXT_JPG
public static final java.lang.String EXT_WBMP
Constructor Detail |
public MimeTypeMap()
public MimeTypeMap(java.io.InputStream input) throws java.io.IOException
input
- an input stream.
java.io.IOException
- for an incorrect stream.public MimeTypeMap(java.io.File file) throws java.io.IOException
java.io.IOException
- for an incorrect input file.public MimeTypeMap(java.lang.String path) throws java.io.IOException
path
- an input file path.
java.io.IOException
- for an incorrect input file.Method Detail |
protected static MimeTypeMapper loadPath(java.lang.String path) throws java.io.IOException
path
- a file path.
java.io.IOException
- for an incorrect file.protected static MimeTypeMapper loadResource(java.lang.String name)
name
- a resource name.
public void setContentType(java.lang.String spec)
spec
- a MIME type extension specification to set.public java.lang.String getContentType(java.io.File file)
file
- the file.
public java.lang.String getContentType(java.lang.String name)
name
- the name of the file.
public java.lang.String getContentType(java.lang.String ext, java.lang.String def)
ext
- the file name extension.def
- the default type if none is found.
public MimeType getMimeContentType(java.io.File file)
file
- the file.
public MimeType getMimeContentType(java.lang.String name)
name
- the name of the file.
public MimeType getMimeContentType(java.lang.String ext, java.lang.String def)
ext
- the file name extension.def
- the default type if none is found.
public java.lang.String getDefaultExtension(java.lang.String type)
type
- the MIME type as a string.
public java.lang.String getDefaultExtension(MimeType mime)
mime
- the MIME type.
protected void setCommonContentType(java.lang.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 |