Search in sources :

Example 1 with DigestingAutoDetectParserFactory

use of org.apache.tika.batch.DigestingAutoDetectParserFactory in project tika by apache.

the class AppParserFactoryBuilder method build.

@Override
public ParserFactory build(Node node, Map<String, String> runtimeAttrs) {
    Map<String, String> localAttrs = XMLDOMUtil.mapifyAttrs(node, runtimeAttrs);
    String className = localAttrs.get("class");
    ParserFactory pf = ClassLoaderUtil.buildClass(ParserFactory.class, className);
    if (localAttrs.containsKey("parseRecursively")) {
        String bString = localAttrs.get("parseRecursively").toLowerCase(Locale.ENGLISH);
        if (bString.equals("true")) {
            pf.setParseRecursively(true);
        } else if (bString.equals("false")) {
            pf.setParseRecursively(false);
        } else {
            throw new RuntimeException("parseRecursively must have value of \"true\" or \"false\": " + bString);
        }
    }
    if (pf instanceof DigestingAutoDetectParserFactory) {
        DigestingParser.Digester d = buildDigester(localAttrs);
        ((DigestingAutoDetectParserFactory) pf).setDigester(d);
    }
    return pf;
}
Also used : ParserFactory(org.apache.tika.batch.ParserFactory) DigestingAutoDetectParserFactory(org.apache.tika.batch.DigestingAutoDetectParserFactory) DigestingAutoDetectParserFactory(org.apache.tika.batch.DigestingAutoDetectParserFactory) DigestingParser(org.apache.tika.parser.DigestingParser)

Aggregations

DigestingAutoDetectParserFactory (org.apache.tika.batch.DigestingAutoDetectParserFactory)1 ParserFactory (org.apache.tika.batch.ParserFactory)1 DigestingParser (org.apache.tika.parser.DigestingParser)1