org.apache.tika.mime
Class MediaType

java.lang.Object
  extended by org.apache.tika.mime.MediaType
All Implemented Interfaces:
Serializable, Comparable<MediaType>

public final class MediaType
extends Object
implements Comparable<MediaType>, Serializable

Internet media type.

See Also:
Serialized Form

Field Summary
static MediaType APPLICATION_XML
           
static MediaType APPLICATION_ZIP
           
static MediaType OCTET_STREAM
           
static MediaType TEXT_PLAIN
           
 
Constructor Summary
MediaType(MediaType type, Map<String,String> parameters)
           
MediaType(String type, String subtype)
           
MediaType(String type, String subtype, Map<String,String> parameters)
           
 
Method Summary
static MediaType application(String type)
           
static MediaType audio(String type)
           
 int compareTo(MediaType that)
           
 boolean equals(Object object)
           
 MediaType getBaseType()
           
 Map<String,String> getParameters()
          Returns an immutable sorted map of the parameters of this media type.
 String getSubtype()
           
 String getType()
           
 int hashCode()
           
 boolean hasParameters()
          Checks whether this media type contains parameters.
static MediaType image(String type)
           
static MediaType parse(String string)
          Parses the given string to a media type.
static MediaType text(String type)
           
 String toString()
           
static MediaType video(String type)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

OCTET_STREAM

public static final MediaType OCTET_STREAM

TEXT_PLAIN

public static final MediaType TEXT_PLAIN

APPLICATION_XML

public static final MediaType APPLICATION_XML

APPLICATION_ZIP

public static final MediaType APPLICATION_ZIP
Constructor Detail

MediaType

public MediaType(String type,
                 String subtype,
                 Map<String,String> parameters)

MediaType

public MediaType(String type,
                 String subtype)

MediaType

public MediaType(MediaType type,
                 Map<String,String> parameters)
Method Detail

application

public static MediaType application(String type)

audio

public static MediaType audio(String type)

image

public static MediaType image(String type)

text

public static MediaType text(String type)

video

public static MediaType video(String type)

parse

public static MediaType parse(String string)
Parses the given string to a media type. The string is expected to be of the form "type/subtype(; parameter=...)*" as defined in RFC 2045, though we also handle "charset=xxx; type/subtype" for broken web servers.

Parameters:
string - media type string to be parsed
Returns:
parsed media type, or null if parsing fails

getBaseType

public MediaType getBaseType()

getType

public String getType()

getSubtype

public String getSubtype()

hasParameters

public boolean hasParameters()
Checks whether this media type contains parameters.

Returns:
true if this type has one or more parameters, false otherwise
Since:
Apache Tika 0.8

getParameters

public Map<String,String> getParameters()
Returns an immutable sorted map of the parameters of this media type. The parameter names are guaranteed to be trimmed and in lower case.

Returns:
sorted map of parameters

toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object object)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

compareTo

public int compareTo(MediaType that)
Specified by:
compareTo in interface Comparable<MediaType>


Copyright © 2007-2011 The Apache Software Foundation. All Rights Reserved.