|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectccs.mime.MimeRegistry
public class MimeRegistry
This utility provides mappings between a list of MIME types, the (many) filename extensions which correspond to that type, and extra information about that MIME type.
| Constructor Summary | |
|---|---|
MimeRegistry()
Creates an empty MIME registry. |
|
| Method Summary | |
|---|---|
void |
clear()
Empty the MimeRegistry completely. |
static MimeRegProvider |
defaultProvider()
A default MimeRegistry-provider. |
MimeType[] |
getMimeTypes()
Obtains the list of MIME types. |
MimeType |
infoForType(java.lang.String mimetype)
Returns the available information for a given MIME type |
void |
loadDefault()
loads the default set of MIME types into the registry. |
void |
marshalTo(java.io.DataOutputStream dest)
Marshals the MIME registry onto the supplied stream. |
java.lang.String |
mimeTypeFor(java.lang.String path)
Deprecated. This method is unreliable. Use the version with two parameters instead. |
java.lang.String |
mimeTypeFor(java.lang.String path,
char separator)
Utility function to return the MIME type of a given file based on its filename extension. |
java.lang.String |
mimeTypeFor(java.net.URLConnection conn)
Utility function to work out the MIME type of a given URLConnection. |
void |
register(MimeType mt)
Add a MimeType to the registry. |
MimeType |
typeForExtension(java.lang.String extn)
Returns the MimeType corresponding to a given extension. |
MimeType |
typeForPath(java.lang.String path)
Deprecated. This is unreliable. Use the two-parameter version instead, or use MUtil.getExtn directly. |
MimeType |
typeForPath(java.lang.String path,
char separator)
Wrapper to extract the extension from a path or filename. |
void |
unmarshalFrom(java.io.DataInputStream src)
Unmarshals the MIME registry from the supplied stream. |
void |
unregister(MimeType mt)
remove a MimeType from the registry. |
void |
xmlMarshal(CXTStream cxt)
Marshals the MIME registry as XML. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MimeRegistry()
| Method Detail |
|---|
public MimeType infoForType(java.lang.String mimetype)
mimetype - The type string ("text/html" or whatever).
public MimeType typeForExtension(java.lang.String extn)
extn - The extension. The leading '.' is required.
public MimeType typeForPath(java.lang.String path)
MUtil.getExtn directly.
path - The path or filename of the file.
MimeType for the file, if available.
public MimeType typeForPath(java.lang.String path,
char separator)
path - The path or filename of the file.separator - The separator char on the filesystem the path came from.
'\\' for Win32, '/' for everything else.
MimeType for the file, if available.public void clear()
public void register(MimeType mt)
mt - The MimeType to add.
LoseException - If the type is already registered, or claims an
extension that is already owned by another type.
public void unregister(MimeType mt)
throws LoseException
mt - the MimeType to remove.
LoseException - If the type is not registered here.public MimeType[] getMimeTypes()
public void marshalTo(java.io.DataOutputStream dest)
throws java.io.IOException
dest - The stream to marshal onto.
java.io.IOException - If thrown by the stream.
public void unmarshalFrom(java.io.DataInputStream src)
throws java.io.IOException
src - The stream to unmarshal from.
java.io.IOException - If thrown by the stream.
public void xmlMarshal(CXTStream cxt)
throws java.io.IOException
cxt - The stream to marshal to
java.io.IOException - If thrown by the stream.public java.lang.String mimeTypeFor(java.net.URLConnection conn)
application/octet-stream.
conn - The URLConnection.
public java.lang.String mimeTypeFor(java.lang.String path)
application/octet-stream.
path - The path or filename of the file.
typeForPath
public java.lang.String mimeTypeFor(java.lang.String path,
char separator)
application/octet-stream.
path - The path or filename of the file.separator - The separator char of the filesystem the path comes from.
typeForPath
public void loadDefault()
throws LoseException,
java.io.IOException
LoseException - If there is a conflict with any pre-existing types.
java.io.IOException - If there is an I/O failure during the load.public static MimeRegProvider defaultProvider()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||