package ch.werner_randelshofer.activation;/*Copyright (C) 1999-99 Werner Randelshoferwerner.randelshofer@mythen.chhttp://www.mythen.ch/w.randelshofer/    Permission to use this release of IFFCTD is herebygranted without fee provided that the complete copyrightnotice and this permission notice appear in all copiesand in supporting documentation.*/import java.io.*;import java.net.*;import ch.werner_randelshofer.iff.*;/**This content type detector can identify IFF files.@author	Werner Randelshofer, Staldenmattweg 2, CH-6405 Immensee, Switzerland.@version	1998-06-12	Created.*/public class IFFCTDimplements ContentTypeDetector	{	/**	Return the number of bytes needed to	determine the content type.	*/ 	public int getMinimalDeterminableDataLength()		{		return 12;		}	/**	Return the base MIME Type of this data. This method is	expected to ALWAYS return a valid (non-null) MIME Type.	I suggest that if the DataTypeDetector implementation cannot 	determine the type of the data, it use the convention of	returning "application/octet-stream".	<p>Returns "x-iff/*contenttype*" for IFF FORM files, where as	*contenttype* stands for the FORM type. e.g. returns "x-iff/ANIM"	for IFF ANIM files.	.	<br>Returns "x-iff/LIST" for IFF LIST files.	<br>Returns "x-iff/CAT" for IFF CAT files.	@param	the first few bytes of the data file.	@return MIME Type	*/	public String getContentType(byte[] dataSnippet)		{		int fileID =			(dataSnippet[0] & 0xff) << 24 |			(dataSnippet[1] & 0xff) << 16|			(dataSnippet[2] & 0xff) << 8 |			(dataSnippet[3] & 0xff);		int contentID =			(dataSnippet[8] & 0xff) << 24 |			(dataSnippet[9] & 0xff) << 16|			(dataSnippet[10] & 0xff) << 8 |			(dataSnippet[11] & 0xff);		if (IFFContext.isFormType(contentID))			{			if (fileID == IFFContext.FORM_ID)				{				return "x-iff/" + IFFContext.idToString(contentID);				}			else if (fileID == IFFContext.CAT_ID)				{				return "x-iff/cat";				}			else if (fileID == IFFContext.LIST_ID)				{				return "x-iff/" + IFFContext.idToString(contentID);				}			}				return ContentTypeDetector.CONTENT_TYPE_UNKNOWN;		}	}