org.apache.nutch.util.mime
Class MimeType

java.lang.Object
  extended by org.apache.nutch.util.mime.MimeType

public final class MimeType
extends Object

Defines a Mime Content Type.

Author:
Jerome Charron - http://frutch.free.fr/, Hari Kodungallur

Constructor Summary
MimeType(String name)
          Creates a MimeType from a String.
MimeType(String primary, String sub)
          Creates a MimeType with the given primary type and sub type.
 
Method Summary
static String clean(String type)
          Cleans a content-type.
 boolean equals(Object object)
          Indicates if an object is equal to this mime-type.
 String getName()
          Return the name of this mime-type.
 String getPrimaryType()
          Return the primary type of this mime-type.
 String getSubType()
          Return the sub type of this mime-type.
 int hashCode()
           
 boolean hasMagic()
           
 boolean matches(byte[] data)
           
 boolean matches(String url)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MimeType

public MimeType(String name)
         throws MimeTypeException
Creates a MimeType from a String.

Parameters:
name - the MIME content type String.
Throws:
MimeTypeException

MimeType

public MimeType(String primary,
                String sub)
         throws MimeTypeException
Creates a MimeType with the given primary type and sub type.

Parameters:
primary - the content type primary type.
sub - the content type sub type.
Throws:
MimeTypeException
Method Detail

clean

public static final String clean(String type)
                          throws MimeTypeException
Cleans a content-type. This method cleans a content-type by removing its optional parameters and returning only its primary-type/sub-type.

Parameters:
type - is the content-type to clean.
Returns:
the cleaned version of the specified content-type.
Throws:
MimeTypeException - if something wrong occurs during the parsing/cleaning of the specified type.

getName

public String getName()
Return the name of this mime-type.

Returns:
the name of this mime-type.

getPrimaryType

public String getPrimaryType()
Return the primary type of this mime-type.

Returns:
the primary type of this mime-type.

getSubType

public String getSubType()
Return the sub type of this mime-type.

Returns:
the sub type of this mime-type.

toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object object)
Indicates if an object is equal to this mime-type. The specified object is equal to this mime-type if it is not null, and it is an instance of MimeType and its name is equals to this mime-type.

Overrides:
equals in class Object
Parameters:
object - the reference object with which to compare.
Returns:
true if this mime-type is equal to the object argument; false otherwise.

hashCode

public int hashCode()
Overrides:
hashCode in class Object

hasMagic

public boolean hasMagic()

matches

public boolean matches(String url)

matches

public boolean matches(byte[] data)


Copyright © 2007, 2012, Oracle and/or its affiliates. All rights reserved.