Copyright 2012-02-25 Werner Randelshofer

ch.randelshofer.activation
Interface Recognizer

All Known Implementing Classes:
AmigaGuideRecognizer, IFFRecognizer, JAIRecognizer, MagicRecognizer, MultiRecognizer, RIFFRecognizer, URLConnectionRecognizer, ZipRecognizer

public interface Recognizer

A recognizer is able to guess the data type of a data stream by inspecting a few bytes at the beginning of the stream.

Version:
1.1 2002-02-12 Return 'application/octet-stream' when file type can not be determined.
1.0 1999-10-19
Author:
Werner Randelshofer, Hausmatt 10, CH-6405 Immensee, Switzerland.

Field Summary
static java.lang.String CONTENT_TYPE_OCTET_STREAM
          This value is returned by #getContentType(byte[]) when the recognizer was not able to determine the content type of the data snippet.
static java.lang.String CONTENT_TYPE_UNKNOWN
          This value is returned by #getContentType(byte[]) when the recognizer was not able to determine the content type of the data snippet.
 
Method Summary
 java.lang.String getContentType(byte[] dataSnippet)
          Return the base MIME Type of this data.
 int getMinimalDeterminableDataLength()
          Return the number of bytes needed to determine the content type.
 

Field Detail

CONTENT_TYPE_UNKNOWN

static final java.lang.String CONTENT_TYPE_UNKNOWN
This value is returned by #getContentType(byte[]) when the recognizer was not able to determine the content type of the data snippet.

See Also:
Constant Field Values

CONTENT_TYPE_OCTET_STREAM

static final java.lang.String CONTENT_TYPE_OCTET_STREAM
This value is returned by #getContentType(byte[]) when the recognizer was not able to determine the content type of the data snippet.

See Also:
Constant Field Values
Method Detail

getMinimalDeterminableDataLength

int getMinimalDeterminableDataLength()
Return the number of bytes needed to determine the content type.


getContentType

java.lang.String getContentType(byte[] dataSnippet)
Return the base MIME Type of this data. This method is expected to ALWAYS return a valid (non-null) MIME Type.

Parameters:
dataSnippet - the first few bytes of the data file.
Returns:
MIME Type or "application/octet-stream" when file type can not be determined.

Copyright 2012-02-25 Werner Randelshofer