/**
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.tika.mime;

import java.util.HashMap;
import java.util.Map;

/**
 * Registry of Internet media types.
 */
public final class MediaTypeRegistry {

    private final Map<MediaType, MediaType> aliases =
        new HashMap<MediaType, MediaType>();

    public void addAlias(MediaType canonical, MediaType alias) {
        aliases.put(alias, canonical);
    }

    public MediaType unalias(MediaType type) {
        MediaType canonical = aliases.get(type.getBaseType());
        if (canonical != null) {
            return new MediaType(canonical, type.getParameters());
        } else {
            return type;
        }
    }

}

@@ -1,15 +1,14 @@
 /*
-*
 %0A * Licensed
@@ -894,16 +894,22 @@
 stry of 
+known 
 Internet
@@ -933,22 +933,16 @@
 %0Apublic 
-final 
 class Me
@@ -959,16 +959,630 @@
 istry %7B%0A
+%0A    /**%0A     * Registry of known media types, including type aliases. All the types%0A     * in this map are base types, i.e. they have no parameters. A canonical%0A     * media type is handled as an identity mapping, while an alias is stored%0A     * as a mapping from the alias to the corresponding canonical type.%0A     */%0A    private final Map%3CMediaType, MediaType%3E registry =%0A        new HashMap%3CMediaType, MediaType%3E();%0A%0A    /**%0A     * Known type inheritance relationships. The mapping is from a media type%0A     * to the closest supertype. All types in this map are canonical and have%0A     * no parameters.%0A     */
 %0A    pri
@@ -1618,23 +1618,27 @@
 iaType%3E 
-aliases
+inheritance
  =%0A     
@@ -1701,13 +1701,12 @@
  add
-Alias
+Type
 (Med
@@ -1716,76 +1716,699 @@
 ype 
-canonical, MediaType alias) %7B%0A        aliases.put(alias, canonical);
+type) %7B%0A        if (type == null %7C%7C type.hasParameters()) %7B%0A            throw new IllegalArgumentException();%0A        %7D else if (registry.containsKey(type)) %7B%0A            throw new IllegalStateException();%0A        %7D else %7B%0A            registry.put(type, type);%0A        %7D%0A    %7D%0A%0A    public void addAlias(MediaType type, MediaType alias) %7B%0A        if (type == null %7C%7C alias == null%0A                %7C%7C type.hasParameters() %7C%7C alias.hasParameters()) %7B%0A            throw new IllegalArgumentException();%0A        %7D else if (!registry.containsKey(type) %7C%7C registry.containsKey(alias)) %7B%0A            throw new IllegalStateException();%0A        %7D else %7B%0A            registry.put(alias, type);%0A        %7D
 %0A   
@@ -2436,15 +2436,17 @@
 ype 
-u
 n
+orm
 ali
-as
+ze
 (Med
@@ -2490,23 +2490,24 @@
 nical = 
-aliases
+registry
 .get(typ
@@ -2546,17 +2546,17 @@
 nonical 
-!
+=
 = null) 
@@ -2553,24 +2553,92 @@
  == null) %7B%0A
+            return type;%0A        %7D else if (type.hasParameters()) %7B%0A
             
@@ -2720,36 +2720,659 @@
          return 
-type
+canonical;%0A        %7D%0A    %7D%0A%0A    public MediaType getSuperType(MediaType type) %7B%0A        if (type.hasParameters()) %7B%0A            return type;%0A        %7D else if (inheritance.containsKey(type)) %7B%0A            return inheritance.get(type);%0A        %7D else if (type.getSubtype().endsWith(%22+xml%22)) %7B%0A            return MediaType.APPLICATION_XML;%0A        %7D else if (%22text%22.equals(type.getType())%0A                && !MediaType.TEXT_PLAIN.equals(type)) %7B%0A            return MediaType.TEXT_PLAIN;%0A        %7D else if (!MediaType.OCTET_STREAM.equals(type)) %7B%0A            return MediaType.OCTET_STREAM;%0A        %7D else %7B%0A            return null
 ;%0A        %7D%0A    

Rename MimeType and MimeTypes