Package org.apache.tika.config
Class TikaConfig
- java.lang.Object
-
- org.apache.tika.config.TikaConfig
-
public class TikaConfig extends Object
Parse xml config file.
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_MAX_JSON_STRING_FIELD_LENGTH
static String
MAX_JSON_STRING_FIELD_LENGTH_ELEMENT_NAME
protected static AtomicInteger
TIMES_INSTANTIATED
-
Constructor Summary
Constructors Constructor Description TikaConfig()
Creates a default Tika configuration.TikaConfig(File file)
TikaConfig(File file, ServiceLoader loader)
TikaConfig(InputStream stream)
TikaConfig(ClassLoader loader)
Creates a Tika configuration from the built-in media type rules and all theParser
implementations available through theservice provider mechanism
in the given class loader.TikaConfig(String file)
TikaConfig(URL url)
TikaConfig(URL url, ClassLoader loader)
TikaConfig(URL url, ServiceLoader loader)
TikaConfig(Path path)
TikaConfig(Path path, ServiceLoader loader)
TikaConfig(Document document)
TikaConfig(Document document, ServiceLoader loader)
TikaConfig(Element element)
TikaConfig(Element element, ClassLoader loader)
-
Method Summary
-
-
-
Field Detail
-
DEFAULT_MAX_JSON_STRING_FIELD_LENGTH
public static int DEFAULT_MAX_JSON_STRING_FIELD_LENGTH
-
MAX_JSON_STRING_FIELD_LENGTH_ELEMENT_NAME
public static String MAX_JSON_STRING_FIELD_LENGTH_ELEMENT_NAME
-
TIMES_INSTANTIATED
protected static final AtomicInteger TIMES_INSTANTIATED
-
-
Constructor Detail
-
TikaConfig
public TikaConfig(String file) throws TikaException, IOException, SAXException
- Throws:
TikaException
IOException
SAXException
-
TikaConfig
public TikaConfig(Path path) throws TikaException, IOException, SAXException
- Throws:
TikaException
IOException
SAXException
-
TikaConfig
public TikaConfig(Path path, ServiceLoader loader) throws TikaException, IOException, SAXException
- Throws:
TikaException
IOException
SAXException
-
TikaConfig
public TikaConfig(File file) throws TikaException, IOException, SAXException
- Throws:
TikaException
IOException
SAXException
-
TikaConfig
public TikaConfig(File file, ServiceLoader loader) throws TikaException, IOException, SAXException
- Throws:
TikaException
IOException
SAXException
-
TikaConfig
public TikaConfig(URL url) throws TikaException, IOException, SAXException
- Throws:
TikaException
IOException
SAXException
-
TikaConfig
public TikaConfig(URL url, ClassLoader loader) throws TikaException, IOException, SAXException
- Throws:
TikaException
IOException
SAXException
-
TikaConfig
public TikaConfig(URL url, ServiceLoader loader) throws TikaException, IOException, SAXException
- Throws:
TikaException
IOException
SAXException
-
TikaConfig
public TikaConfig(InputStream stream) throws TikaException, IOException, SAXException
- Throws:
TikaException
IOException
SAXException
-
TikaConfig
public TikaConfig(Document document) throws TikaException, IOException
- Throws:
TikaException
IOException
-
TikaConfig
public TikaConfig(Document document, ServiceLoader loader) throws TikaException, IOException
- Throws:
TikaException
IOException
-
TikaConfig
public TikaConfig(Element element) throws TikaException, IOException
- Throws:
TikaException
IOException
-
TikaConfig
public TikaConfig(Element element, ClassLoader loader) throws TikaException, IOException
- Throws:
TikaException
IOException
-
TikaConfig
public TikaConfig(ClassLoader loader) throws MimeTypeException, IOException
Creates a Tika configuration from the built-in media type rules and all theParser
implementations available through theservice provider mechanism
in the given class loader.- Parameters:
loader
- the class loader through which parser implementations are loaded, ornull
for no parsers- Throws:
MimeTypeException
- if the built-in media type rules are brokenIOException
- if the built-in media type rules can not be read- Since:
- Apache Tika 0.8
-
TikaConfig
public TikaConfig() throws TikaException, IOException
Creates a default Tika configuration. First checks whether an XML config file is specified, either in- System property "tika.config", or
- Environment variable TIKA_CONFIG
If one of these have a value, try to resolve it relative to file system or classpath.
If XML config is not specified, initialize from the built-in media type rules and all the
Parser
implementations available through theservice provider mechanism
in the context class loader of the current thread.- Throws:
IOException
- if the configuration can not be readTikaException
- if problem with MimeTypes or parsing XML config
-
-
Method Detail
-
getMaxJsonStringFieldLength
public static int getMaxJsonStringFieldLength()
- Returns:
- maximum field length when serializing String fields in Tika's metadata or metadata list into JSON
-
getDefaultDetector
protected static CompositeDetector getDefaultDetector(MimeTypes types, ServiceLoader loader)
-
getDefaultEncodingDetector
protected static CompositeEncodingDetector getDefaultEncodingDetector(ServiceLoader loader)
-
getDefaultRenderer
protected static CompositeRenderer getDefaultRenderer(ServiceLoader loader)
-
getDefaultConfig
public static TikaConfig getDefaultConfig()
Provides a default configuration (TikaConfig). Currently creates a new instance each time it's called; we may be able to have it return a shared instance once it is completely immutable.- Returns:
- default configuration
-
mustNotBeEmpty
public static void mustNotBeEmpty(String paramName, String paramValue) throws TikaConfigException
- Throws:
TikaConfigException
-
mustNotBeEmpty
public static void mustNotBeEmpty(String paramName, Path paramValue) throws TikaConfigException
- Throws:
TikaConfigException
-
getParser
public Parser getParser(MediaType mimeType)
Deprecated.Use thegetParser()
method instead
-
getParser
public Parser getParser()
Returns the configured parser instance.- Returns:
- configured parser
-
getDetector
public Detector getDetector()
Returns the configured detector instance.- Returns:
- configured detector
-
getEncodingDetector
public EncodingDetector getEncodingDetector()
Returns the configured encoding detector instance- Returns:
- configured encoding detector
-
getTranslator
public Translator getTranslator()
Returns the configured translator instance.- Returns:
- configured translator
-
getExecutorService
public ExecutorService getExecutorService()
-
getMimeRepository
public MimeTypes getMimeRepository()
-
getMediaTypeRegistry
public MediaTypeRegistry getMediaTypeRegistry()
-
getServiceLoader
public ServiceLoader getServiceLoader()
-
getMetadataFilter
public MetadataFilter getMetadataFilter()
-
getAutoDetectParserConfig
public AutoDetectParserConfig getAutoDetectParserConfig()
-
-