org.apache.tika.mime
Class MediaTypeRegistry

java.lang.Object
  extended by org.apache.tika.mime.MediaTypeRegistry
All Implemented Interfaces:
Serializable

public class MediaTypeRegistry
extends Object
implements Serializable

Registry of known Internet media types.

See Also:
Serialized Form

Constructor Summary
MediaTypeRegistry()
           
 
Method Summary
 void addAlias(MediaType type, MediaType alias)
           
 void addSuperType(MediaType type, MediaType supertype)
           
 void addType(MediaType type)
           
 SortedSet<MediaType> getAliases(MediaType type)
          Returns the set of known aliases of the given canonical media type.
static MediaTypeRegistry getDefaultRegistry()
          Returns the built-in media type registry included in Tika.
 MediaType getSupertype(MediaType type)
          Returns the supertype of the given type.
 SortedSet<MediaType> getTypes()
          Returns the set of all known canonical media types.
 boolean isSpecializationOf(MediaType a, MediaType b)
          Checks whether the given media type a is a specialization of a more generic type b.
 MediaType normalize(MediaType type)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MediaTypeRegistry

public MediaTypeRegistry()
Method Detail

getDefaultRegistry

public static MediaTypeRegistry getDefaultRegistry()
Returns the built-in media type registry included in Tika.

Returns:
default media type registry
Since:
Apache Tika 0.8

getTypes

public SortedSet<MediaType> getTypes()
Returns the set of all known canonical media types. Type aliases are not included in the returned set.

Returns:
canonical media types
Since:
Apache Tika 0.8

getAliases

public SortedSet<MediaType> getAliases(MediaType type)
Returns the set of known aliases of the given canonical media type.

Parameters:
type - canonical media type
Returns:
known aliases
Since:
Apache Tika 0.8

addType

public void addType(MediaType type)

addAlias

public void addAlias(MediaType type,
                     MediaType alias)

addSuperType

public void addSuperType(MediaType type,
                         MediaType supertype)

normalize

public MediaType normalize(MediaType type)

isSpecializationOf

public boolean isSpecializationOf(MediaType a,
                                  MediaType b)
Checks whether the given media type a is a specialization of a more generic type b.

Parameters:
a - media type
b - suspected supertype
Returns:
true if b is a supertype of a, false otherwise
Since:
Apache Tika 0.8

getSupertype

public MediaType getSupertype(MediaType type)
Returns the supertype of the given type. If the given type has any parameters, then the respective base type is returned. Otherwise built-in heuristics like text/... -> text/plain and .../...+xml -> application/xml are used in addition to explicit type inheritance rules read from the media type database. Finally application/octet-stream is returned for all types for which no other supertype is known, and the return value for application/octet-stream is null.

Parameters:
type - media type
Returns:
supertype, or null for application/octet-stream
Since:
Apache Tika 0.8


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