|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--com.mirrorworlds.lifestreams.mail.tnef.DefaultContentTypeImpl
Default implementation for the tnef content-type map. Note that the methods in this class are not synchronized i.e. not thread safe.
To save the 72 preconfigured entries to a file from the command line:
java com.mirrorworlds.lifestreams.mail.tnef.DefaultContentTypeImpl mimetypes.txt
| Constructor Summary | |
DefaultContentTypeImpl()
Creates and initialize a list of file extensions and associated mime content-types. |
|
| Method Summary | |
void |
addType(java.lang.String ext,
java.lang.String contentType)
Lets subclasses add extension and content-types. |
java.util.Enumeration |
contentTypes()
Returns an Enumeration to the current mime types. |
java.util.Enumeration |
extensions()
Returns an Enumeration to the current file extensions. |
java.lang.String |
getContentTypeFromExtension(java.lang.String ext)
Returns the MIME content type given a file extension. |
java.lang.String |
getContentTypeFromFilename(java.lang.String filename)
Returns the MIME content type given a file name. |
int |
getSize()
|
void |
load(java.io.InputStream i,
boolean clear)
Loads the extension|content-type from an (text)inputstream. |
static void |
main(java.lang.String[] args)
|
void |
removeContentType(java.lang.String contentType)
Lets subclasses remove content-type and its associated file extensions. |
void |
removeExtension(java.lang.String ext)
Lets subclasses remove extension and its associated content-type. |
void |
writeTo(java.io.OutputStream o)
Writes the current list of mime type to the output stream using the format |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Constructor Detail |
public DefaultContentTypeImpl()
| Method Detail |
public int getSize()
public java.util.Enumeration extensions()
public java.util.Enumeration contentTypes()
public void addType(java.lang.String ext,
java.lang.String contentType)
ext - file extensioncontentType - MIME type associated with the file extension.public void removeExtension(java.lang.String ext)
ext - file extensionpublic void removeContentType(java.lang.String contentType)
contentType - MIME content-type.
public void writeTo(java.io.OutputStream o)
throws java.io.IOException
extension [space] mime-type
try {
DefaultContentTypeImpl ct = new DefaultContentTypeImpl();
FileOutputStream fos = new FileOutputStream("types.txt");
ct.writeTo(fos);
fos.close();
}catch(Exception e) {
}
o - outputstream to where the contents are written to.
public void load(java.io.InputStream i,
boolean clear)
throws java.io.IOException
extension [space] mime-type
clear flag is set to true then the current
contents of the registry are cleared prior to loading. Otherwise, the content
are replaced (over written).
For example:
try {
DefaultContentTypeImpl ct = new DefaultContentTypeImpl();
FileInputStream fis = new FileInputStream("my-types.txt");
ct.load(fos,false);
fis.close();
}catch(Exception e) {
}
Any line begining with the pound (#) sign is assumed to be a
comment and is ignored.i - inputstream of ext/mime-type contentsclear - if true,clears the current contents prior to loading.public java.lang.String getContentTypeFromExtension(java.lang.String ext)
ext - file extentsion.public java.lang.String getContentTypeFromFilename(java.lang.String filename)
name - file name with extentsion.public static void main(java.lang.String[] args)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||