org.apache.tika.parser
Class AutoDetectParser

java.lang.Object
  extended by org.apache.tika.parser.CompositeParser
      extended by org.apache.tika.parser.AutoDetectParser
All Implemented Interfaces:
Parser

public class AutoDetectParser
extends CompositeParser


Constructor Summary
AutoDetectParser()
          Creates an auto-detecting parser instance using the default Tika configuration.
AutoDetectParser(TikaConfig config)
           
 
Method Summary
 Detector getDetector()
          Returns the type detector used by this parser to auto-detect the type of a document.
 void parse(java.io.InputStream stream, org.xml.sax.ContentHandler handler, Metadata metadata)
          The parse() method from Tika 0.4 and earlier.
 void parse(java.io.InputStream stream, org.xml.sax.ContentHandler handler, Metadata metadata, ParseContext context)
          Delegates the call to the matching component parser.
 void setConfig(TikaConfig config)
           
 void setDetector(Detector detector)
          Sets the type detector used by this parser to auto-detect the type of a document.
 
Methods inherited from class org.apache.tika.parser.CompositeParser
getFallback, getParser, getParsers, setFallback, setParsers
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AutoDetectParser

public AutoDetectParser()
Creates an auto-detecting parser instance using the default Tika configuration.


AutoDetectParser

public AutoDetectParser(TikaConfig config)
Method Detail

setConfig

public void setConfig(TikaConfig config)

getDetector

public Detector getDetector()
Returns the type detector used by this parser to auto-detect the type of a document.

Returns:
type detector
Since:
Apache Tika 0.4

setDetector

public void setDetector(Detector detector)
Sets the type detector used by this parser to auto-detect the type of a document. Note that calling the setConfig(TikaConfig) method will override the type detector setting with the type settings included in the given configuration.

Parameters:
detector - type detector
Since:
Apache Tika 0.4

parse

public void parse(java.io.InputStream stream,
                  org.xml.sax.ContentHandler handler,
                  Metadata metadata,
                  ParseContext context)
           throws java.io.IOException,
                  org.xml.sax.SAXException,
                  TikaException
Description copied from class: CompositeParser
Delegates the call to the matching component parser.

Potential RuntimeExceptions, IOExceptions and SAXExceptions unrelated to the given input stream and content handler are automatically wrapped into TikaExceptions to better honor the Parser contract.

Specified by:
parse in interface Parser
Overrides:
parse in class CompositeParser
Parameters:
stream - the document stream (input)
handler - handler for the XHTML SAX events (output)
metadata - document metadata (input and output)
context - parse context
Throws:
java.io.IOException - if the document stream could not be read
org.xml.sax.SAXException - if the SAX events could not be processed
TikaException - if the document could not be parsed

parse

public void parse(java.io.InputStream stream,
                  org.xml.sax.ContentHandler handler,
                  Metadata metadata)
           throws java.io.IOException,
                  org.xml.sax.SAXException,
                  TikaException
Description copied from interface: Parser
The parse() method from Tika 0.4 and earlier. Please use the #parse(InputStream, ContentHandler, Metadata, Map) method instead in new code. Calls to this backwards compatibility method are forwarded to the new parse() method with an empty parse context.

Specified by:
parse in interface Parser
Overrides:
parse in class CompositeParser
Throws:
java.io.IOException
org.xml.sax.SAXException
TikaException


Copyright © 2010 The Apache Software Foundation. All Rights Reserved.