FileDocCategorySizeDatePackage
MimeMap.javaAPI DocGlassfish v2 API8814Thu Jun 28 15:09:48 BST 2007org.apache.tomcat.util.http

MimeMap

public class MimeMap extends Object implements FileNameMap
A mime type map that implements the java.net.FileNameMap interface.
author
James Duncan Davidson [duncan@eng.sun.com]
author
Jason Hunter [jch@eng.sun.com]

Fields Summary
public static final Hashtable
defaultMap
private Hashtable
map
Constructors Summary
Methods Summary
public voidaddContentType(java.lang.String extn, java.lang.String type)


          
        map.put(extn, type.toLowerCase());
    
public java.lang.StringgetContentType(java.lang.String extn)

        String type = (String)map.get(extn.toLowerCase());
	if( type == null ) type=(String)defaultMap.get( extn );
	return type;
    
public java.lang.StringgetContentTypeFor(java.lang.String fileName)

	String extn=getExtension( fileName );
        if (extn!=null) {
            return getContentType(extn);
        } else {
            // no extension, no content type
            return null;
        }
    
public static java.lang.StringgetExtension(java.lang.String fileName)
Get extension of file, without fragment id

        // play it safe and get rid of any fragment id
        // that might be there
	int length=fileName.length();
	
        int newEnd = fileName.lastIndexOf('#");
	if( newEnd== -1 ) newEnd=length;
	// Instead of creating a new string.
	//         if (i != -1) {
	//             fileName = fileName.substring(0, i);
	//         }
        int i = fileName.lastIndexOf('.", newEnd );
        if (i != -1) {
             return  fileName.substring(i + 1, newEnd );
        } else {
            // no extension, no content type
            return null;
        }
    
public java.util.EnumerationgetExtensions()

        return map.keys();
    
public voidremoveContentType(java.lang.String extn)

        map.remove(extn.toLowerCase());