Hi, On Sun, Sep 12, 2010 at 5:46 PM, Ken Krugler <kkrugler_li...@transpac.com> wrote: > But that also seems clunky. Any other suggestions?
A simpler approach would be to simply pass a list of already instantiated Parser objects to AutoDetectParser, like this: public AutoDetectParser(Detector detector, Parser... parsers) { setDetector(detector); Map<MediaType, Parser> map = new HashMap<MediaType, Parser>(); ParseContext context = new ParseContext(); for (Parser parser : parsers) { for (MediaType type : parser.getSupportedTypes(context)) { map.put(type, parser); } } setParsers(map); } BTW, the need to pass a MediaType->Parser map to CompositeParser.setParsers() is a remnant of the time when we didn't have the Parser.getSupportedTypes() method. Nowadays it would probably be better to simply pass a collection of parsers and use getSupportedTypes() calls for dispatch during CompositeParser.parse(). > As an aside, what's the standard use case for specifying an explicit > classloader? I haven't seen this used in other projects, so I'm curious. See TIKA-419 [1] the relevant background. [1] https://issues.apache.org/jira/browse/TIKA-419 BR, Jukka Zitting