protected Parser getParser(Metadata metadata, ParseContext context) {
        Map<MediaType, Parser> map = getParsers(context);
        //check for parser override first
        String contentTypeString = metadata.get(TikaCoreProperties.CONTENT_TYPE_PARSER_OVERRIDE);
        if (contentTypeString == null) {
            contentTypeString = metadata.get(Metadata.CONTENT_TYPE);
        }
        MediaType type = MediaType.parse(contentTypeString);
        if (type != null) {
            // We always work on the normalised, canonical form
            type = registry.normalize(type);
        }
        while (type != null) {
            // Try finding a parser for the type
            Parser parser = map.get(type);
            if (parser != null) {
                return parser;
            }

            // Failing that, try for the parent of the type
            type = registry.getSupertype(type);
        }
        return fallback;
    }
Returns the parser that best matches the given metadata. By default
looks for a parser that matches the content type metadata property,
and uses the fallback parser if a better match is not found. The
type hierarchy information included in the configured media type
registry is used when looking for a matching parser instance.
<p>
Subclasses can override this method to provide more accurate
parser resolution.

@param metadata document metadata
@return matching parser
tika-core/src/main/java/org/apache/tika/parser/CompositeParser.java