|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.nutch.util.mime.MimeTypes
public final class MimeTypes
This class is a MimeType repository. It gathers a set of MimeTypes and enables to retrieves a content-type from a specified file extension, or from a magic character sequence (or both).
Field Summary | |
---|---|
static String |
DEFAULT
The default application/octet-stream MimeType |
Method Summary | |
---|---|
MimeType |
forName(String name)
Return a MimeType from its name. |
static MimeTypes |
get(String filepath,
Configuration conf)
Return a MimeTypes instance. |
static MimeTypes |
get(String filepath,
org.apache.commons.logging.Log logger,
Configuration conf)
Return a MimeTypes instance. |
MimeType |
getMimeType(byte[] data)
Find the Mime Content Type of a stream from its content. |
MimeType |
getMimeType(File file)
Find the Mime Content Type of a file. |
MimeType |
getMimeType(String name)
Find the Mime Content Type of a document from its name. |
MimeType |
getMimeType(String name,
byte[] data)
Find the Mime Content Type of a document from its name and its content. |
MimeType |
getMimeType(URL url)
Find the Mime Content Type of a document from its URL. |
int |
getMinLength()
Return the minimum length of data to provide to analyzing methods based on the document's content in order to check all the known MimeTypes. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String DEFAULT
application/octet-stream
MimeType
Method Detail |
---|
public static MimeTypes get(String filepath, Configuration conf)
filepath
- is the mime-types definitions xml file.
public static MimeTypes get(String filepath, org.apache.commons.logging.Log logger, Configuration conf)
filepath
- is the mime-types definitions xml file.logger
- is it Logger to uses for ouput messages.
public MimeType getMimeType(File file)
file
- to analyze.
null
if none is found.public MimeType getMimeType(URL url)
url
- of the document to analyze.
null
if none is found.public MimeType getMimeType(String name)
name
- of the document to analyze.
null
if none is found.public MimeType getMimeType(byte[] data)
data
- are the first bytes of data of the content to analyze.
Depending on the length of provided data, all known MimeTypes are
checked. If the length of provided data is greater or egals to
the value returned by getMinLength()
, then all known
MimeTypes are checked, otherwise only the MimeTypes that could be
analyzed with the length of provided data are analyzed.
null
if none is found.getMinLength()
public MimeType getMimeType(String name, byte[] data)
name
- of the document to analyze.data
- are the first bytes of the document's content.
null
if none is found.getMinLength()
public MimeType forName(String name)
public int getMinLength()
getMimeType(byte[])
,
getMimeType(String, byte[])
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |