You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tika.apache.org by ni...@apache.org on 2018/04/08 12:14:26 UTC
[tika] 02/05: Pass the params to the composite parser constructors
This is an automated email from the ASF dual-hosted git repository.
nick pushed a commit to branch multiple-parsers
in repository https://gitbox.apache.org/repos/asf/tika.git
commit be246f1d395007efc26e6e1648ed6dc2912c2efa
Author: Nick Burch <ni...@gagravarr.org>
AuthorDate: Sun Apr 8 10:43:05 2018 +0100
Pass the params to the composite parser constructors
---
.../java/org/apache/tika/config/TikaConfig.java | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/tika-core/src/main/java/org/apache/tika/config/TikaConfig.java b/tika-core/src/main/java/org/apache/tika/config/TikaConfig.java
index 5b1b1ab..ab6e23f 100644
--- a/tika-core/src/main/java/org/apache/tika/config/TikaConfig.java
+++ b/tika-core/src/main/java/org/apache/tika/config/TikaConfig.java
@@ -63,6 +63,7 @@ import org.apache.tika.parser.DefaultParser;
import org.apache.tika.parser.ParseContext;
import org.apache.tika.parser.Parser;
import org.apache.tika.parser.ParserDecorator;
+import org.apache.tika.parser.multiple.AbstractMultipleParser;
import org.apache.tika.utils.AnnotationUtils;
import org.apache.tika.utils.XMLReaderUtils;
import org.w3c.dom.Document;
@@ -537,8 +538,8 @@ public class TikaConfig {
abstract CT createDefault(MimeTypes mimeTypes, ServiceLoader loader);
abstract CT createComposite(List<T> loaded, MimeTypes mimeTypes, ServiceLoader loader);
abstract T createComposite(Class<? extends T> compositeClass,
- List<T> children, Set<Class<? extends T>> excludeChildren,
- MimeTypes mimeTypes, ServiceLoader loader)
+ List<T> children, Set<Class<? extends T>> excludeChildren,
+ Map<String, Param> params, MimeTypes mimeTypes, ServiceLoader loader)
throws InvocationTargetException, IllegalAccessException, InstantiationException;
abstract T decorate(T created, Element element)
throws IOException, TikaException; // eg explicit mime types
@@ -596,6 +597,9 @@ public class TikaConfig {
loaded = preLoadOne(loadedClass, name, mimeTypes);
if (loaded != null) return loaded;
+ // Get any parameters / settings for the parser
+ Map<String, Param> params = getParams(element);
+
// Is this a composite or decorated class? If so, support recursion
if (isComposite(loadedClass)) {
// Get the child objects for it
@@ -621,7 +625,7 @@ public class TikaConfig {
}
// Create the Composite
- loaded = createComposite(loadedClass, children, excludeChildren, mimeTypes, loader);
+ loaded = createComposite(loadedClass, children, excludeChildren, params, mimeTypes, loader);
// Default constructor fallback
if (loaded == null) {
@@ -634,7 +638,6 @@ public class TikaConfig {
// See the thread "Configuring parsers and translators" for details
}
- Map<String, Param> params = getParams(element);
//Assigning the params to bean fields/setters
AnnotationUtils.assignFieldParams(loaded, params);
if (loaded instanceof Initializable) {
@@ -738,6 +741,7 @@ public class TikaConfig {
@Override
boolean isComposite(Class<? extends Parser> loadedClass) {
if (CompositeParser.class.isAssignableFrom(loadedClass) ||
+ AbstractMultipleParser.class.isAssignableFrom(loadedClass) ||
ParserDecorator.class.isAssignableFrom(loadedClass)) {
return true;
}
@@ -755,7 +759,7 @@ public class TikaConfig {
@Override
Parser createComposite(Class<? extends Parser> parserClass,
List<Parser> childParsers, Set<Class<? extends Parser>> excludeParsers,
- MimeTypes mimeTypes, ServiceLoader loader)
+ Map<String, Param> params, MimeTypes mimeTypes, ServiceLoader loader)
throws InvocationTargetException, IllegalAccessException, InstantiationException {
Parser parser = null;
Constructor<? extends Parser> c = null;
@@ -878,7 +882,7 @@ public class TikaConfig {
Detector createComposite(Class<? extends Detector> detectorClass,
List<Detector> childDetectors,
Set<Class<? extends Detector>> excludeDetectors,
- MimeTypes mimeTypes, ServiceLoader loader)
+ Map<String, Param> params, MimeTypes mimeTypes, ServiceLoader loader)
throws InvocationTargetException, IllegalAccessException,
InstantiationException {
Detector detector = null;
@@ -951,7 +955,7 @@ public class TikaConfig {
Translator createComposite(Class<? extends Translator> compositeClass,
List<Translator> children,
Set<Class<? extends Translator>> excludeChildren,
- MimeTypes mimeTypes, ServiceLoader loader)
+ Map<String, Param> params, MimeTypes mimeTypes, ServiceLoader loader)
throws InvocationTargetException, IllegalAccessException,
InstantiationException {
throw new InstantiationException("Only one translator supported");
@@ -968,7 +972,7 @@ public class TikaConfig {
Class<? extends ConfigurableThreadPoolExecutor> compositeClass,
List<ConfigurableThreadPoolExecutor> children,
Set<Class<? extends ConfigurableThreadPoolExecutor>> excludeChildren,
- MimeTypes mimeTypes, ServiceLoader loader)
+ Map<String, Param> params, MimeTypes mimeTypes, ServiceLoader loader)
throws InvocationTargetException, IllegalAccessException,
InstantiationException {
throw new InstantiationException("Only one executor service supported");
@@ -1090,7 +1094,7 @@ public class TikaConfig {
EncodingDetector createComposite(Class<? extends EncodingDetector> encodingDetectorClass,
List<EncodingDetector> childEncodingDetectors,
Set<Class<? extends EncodingDetector>> excludeDetectors,
- MimeTypes mimeTypes, ServiceLoader loader)
+ Map<String, Param> params, MimeTypes mimeTypes, ServiceLoader loader)
throws InvocationTargetException, IllegalAccessException,
InstantiationException {
EncodingDetector encodingDetector = null;
--
To stop receiving notification emails like this one, please contact
nick@apache.org.