com.ccg.net
Class MimeTypes

java.lang.Object
  extended by com.ccg.net.MimeTypes
All Implemented Interfaces:
FileNameMap

public final class MimeTypes
extends Object
implements FileNameMap

Used to keep track of a large set of MimeType objects (offering a mechanism to guess mime type from file extension).

 class Example {
   public void main(String[] args) {
     com.ccg.net.MimeTypes o = new com.ccg.net.MimeTypes();
          System.out.println(o);
   }
 }
 

Since:
1.0
Version:
$Revision: 1.2 $
Author:
$Author: pkb $ #see [class][#method]|Text

Constructor Summary
MimeTypes()
          Initializes object to...
MimeTypes(MimeType[] init)
          Create and initialize your own mime type object.
 
Method Summary
 void add(MimeType mt)
          One line summary...
 String getContentTypeFor(String ext)
          Looks up the content type identifier for a particular file extension.
 MimeType getMimeType(String mt)
          Validates a MIME type string by looking up MIME type object.
 MimeType getMimeTypeForExt(String ext)
          Looks up the content type identifier for a particular file extension.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MimeTypes

public MimeTypes()
Initializes object to... It performs the following tasks:

Since:
1.0 #see [class][#meth]|Text

MimeTypes

public MimeTypes(MimeType[] init)
Create and initialize your own mime type object.

This constructor allows one to create either a empty MimeTypes object, or to initialize it with their own specific set of MimeType objects.

Parameters:
mta - Array of mime type objects to initialize with (or pass null if you want it to initially be empty).
Since:
1.0
Method Detail

getContentTypeFor

public String getContentTypeFor(String ext)
Looks up the content type identifier for a particular file extension.

This method looks up the content type for a particular file extension. For example, if you pass "html" you would get back "text/html".

Specified by:
getContentTypeFor in interface FileNameMap
Parameters:
ext - File extension to look up content type identifier for.
Returns:
The corresponding content type. If we don't find one, we return "unknown/unknown".
Since:
1.0
See Also:
getMimeTypeForExt(java.lang.String)

getMimeTypeForExt

public MimeType getMimeTypeForExt(String ext)
Looks up the content type identifier for a particular file extension.

This method looks up the content type for a particular file extension. For example, if you pass "html" you would get back "text/html".

Parameters:
ext - File extension to look up content type identifier for.
Returns:
The corresponding content type. If we don't find one, we return "unknown/unknown".
Since:
1.0
See Also:
getMimeTypeForExt(java.lang.String)

add

public void add(MimeType mt)
One line summary... Describe...

Parameters:
arg1 - arg1-describe
arg2 - arg2-describe
Throws:
exc - Why thrown
Since:
1.0 #see [class][#meth]|Text

getMimeType

public MimeType getMimeType(String mt)
Validates a MIME type string by looking up MIME type object.

This method is handy to use to validate a MIME type string (to make sure it is one of the MIME types recognized by this table). You pass in a MIME type string (like "text/html") and get back the corresponding MimeType object - or MimeType.UNKNOWN if your string isn't recognized.

WARNING: This is case sensitive (until I determine that MIME types are not case sensative)!

Parameters:
mt - The MIME type (as a string) you want to get the MimeType object for (for example: "text/plain"). You may pass null.
Returns:
The MimeType object we have registered to handle the request, or MimeType.UNKNOWN if we don't recognize your string. Never returns null.
Since:
1.0


Copyright 1998-1998-2006 null. All Rights Reserved.