Class TikaConfig


  • public class TikaConfig
    extends java.lang.Object
    Parse xml config file.
    • Constructor Detail

      • TikaConfig

        public TikaConfig​(java.lang.String file)
                   throws TikaException,
                          java.io.IOException,
                          org.xml.sax.SAXException
        Throws:
        TikaException
        java.io.IOException
        org.xml.sax.SAXException
      • TikaConfig

        public TikaConfig​(java.nio.file.Path path)
                   throws TikaException,
                          java.io.IOException,
                          org.xml.sax.SAXException
        Throws:
        TikaException
        java.io.IOException
        org.xml.sax.SAXException
      • TikaConfig

        public TikaConfig​(java.nio.file.Path path,
                          ServiceLoader loader)
                   throws TikaException,
                          java.io.IOException,
                          org.xml.sax.SAXException
        Throws:
        TikaException
        java.io.IOException
        org.xml.sax.SAXException
      • TikaConfig

        public TikaConfig​(java.io.File file)
                   throws TikaException,
                          java.io.IOException,
                          org.xml.sax.SAXException
        Throws:
        TikaException
        java.io.IOException
        org.xml.sax.SAXException
      • TikaConfig

        public TikaConfig​(java.io.File file,
                          ServiceLoader loader)
                   throws TikaException,
                          java.io.IOException,
                          org.xml.sax.SAXException
        Throws:
        TikaException
        java.io.IOException
        org.xml.sax.SAXException
      • TikaConfig

        public TikaConfig​(java.net.URL url)
                   throws TikaException,
                          java.io.IOException,
                          org.xml.sax.SAXException
        Throws:
        TikaException
        java.io.IOException
        org.xml.sax.SAXException
      • TikaConfig

        public TikaConfig​(java.net.URL url,
                          java.lang.ClassLoader loader)
                   throws TikaException,
                          java.io.IOException,
                          org.xml.sax.SAXException
        Throws:
        TikaException
        java.io.IOException
        org.xml.sax.SAXException
      • TikaConfig

        public TikaConfig​(java.net.URL url,
                          ServiceLoader loader)
                   throws TikaException,
                          java.io.IOException,
                          org.xml.sax.SAXException
        Throws:
        TikaException
        java.io.IOException
        org.xml.sax.SAXException
      • TikaConfig

        public TikaConfig​(java.io.InputStream stream)
                   throws TikaException,
                          java.io.IOException,
                          org.xml.sax.SAXException
        Throws:
        TikaException
        java.io.IOException
        org.xml.sax.SAXException
      • TikaConfig

        public TikaConfig​(org.w3c.dom.Document document)
                   throws TikaException,
                          java.io.IOException
        Throws:
        TikaException
        java.io.IOException
      • TikaConfig

        public TikaConfig​(org.w3c.dom.Element element)
                   throws TikaException,
                          java.io.IOException
        Throws:
        TikaException
        java.io.IOException
      • TikaConfig

        public TikaConfig​(org.w3c.dom.Element element,
                          java.lang.ClassLoader loader)
                   throws TikaException,
                          java.io.IOException
        Throws:
        TikaException
        java.io.IOException
      • TikaConfig

        public TikaConfig​(java.lang.ClassLoader loader)
                   throws MimeTypeException,
                          java.io.IOException
        Creates a Tika configuration from the built-in media type rules and all the Parser implementations available through the service provider mechanism in the given class loader.
        Parameters:
        loader - the class loader through which parser implementations are loaded, or null for no parsers
        Throws:
        MimeTypeException - if the built-in media type rules are broken
        java.io.IOException - if the built-in media type rules can not be read
        Since:
        Apache Tika 0.8
      • TikaConfig

        public TikaConfig()
                   throws TikaException,
                          java.io.IOException
        Creates a default Tika configuration. First checks whether an XML config file is specified, either in
        1. System property "tika.config", or
        2. 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 the service provider mechanism in the context class loader of the current thread.

        Throws:
        java.io.IOException - if the configuration can not be read
        TikaException - if problem with MimeTypes or parsing XML config
    • Method Detail

      • 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 java.util.concurrent.ExecutorService getExecutorService()
      • getMimeRepository

        public MimeTypes getMimeRepository()
      • 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