|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.tika.parser.CompositeParser
public class CompositeParser
Composite parser that delegates parsing tasks to a component parser based on the declared content type of the incoming document. A fallback parser is defined for cases where a parser for the given content type is not available.
Constructor Summary | |
---|---|
CompositeParser()
|
|
CompositeParser(MediaTypeRegistry registry,
java.util.List<Parser> parsers)
|
|
CompositeParser(MediaTypeRegistry registry,
Parser... parsers)
|
Method Summary | |
---|---|
Parser |
getFallback()
Returns the fallback parser. |
MediaTypeRegistry |
getMediaTypeRegistry()
Returns the media type registry used to infer type relationships. |
protected Parser |
getParser(Metadata metadata)
Returns the parser that best matches the given metadata. |
protected Parser |
getParser(Metadata metadata,
ParseContext context)
|
java.util.Map<MediaType,Parser> |
getParsers()
Returns the component parsers. |
java.util.Map<MediaType,Parser> |
getParsers(ParseContext context)
|
java.util.Set<MediaType> |
getSupportedTypes(ParseContext context)
Returns the set of media types supported by this parser when used with the given parse context. |
void |
parse(java.io.InputStream stream,
org.xml.sax.ContentHandler handler,
Metadata metadata)
Deprecated. This method will be removed in Apache Tika 1.0. |
void |
parse(java.io.InputStream stream,
org.xml.sax.ContentHandler handler,
Metadata metadata,
ParseContext context)
Delegates the call to the matching component parser. |
void |
setFallback(Parser fallback)
Sets the fallback parser. |
void |
setMediaTypeRegistry(MediaTypeRegistry registry)
Sets the media type registry used to infer type relationships. |
void |
setParsers(java.util.Map<MediaType,Parser> parsers)
Sets the component parsers. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CompositeParser(MediaTypeRegistry registry, java.util.List<Parser> parsers)
public CompositeParser(MediaTypeRegistry registry, Parser... parsers)
public CompositeParser()
Method Detail |
---|
public java.util.Map<MediaType,Parser> getParsers(ParseContext context)
public MediaTypeRegistry getMediaTypeRegistry()
public void setMediaTypeRegistry(MediaTypeRegistry registry)
registry
- media type registrypublic java.util.Map<MediaType,Parser> getParsers()
public void setParsers(java.util.Map<MediaType,Parser> parsers)
parsers
- component parsers, keyed by media typepublic Parser getFallback()
public void setFallback(Parser fallback)
fallback
- fallback parserprotected Parser getParser(Metadata metadata)
Subclasses can override this method to provide more accurate parser resolution.
metadata
- document metadata
protected Parser getParser(Metadata metadata, ParseContext context)
public java.util.Set<MediaType> getSupportedTypes(ParseContext context)
Parser
getSupportedTypes
in interface Parser
context
- parse context
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
Potential RuntimeException
s, IOException
s and
SAXException
s unrelated to the given input stream and content
handler are automatically wrapped into TikaException
s to better
honor the Parser
contract.
parse
in interface Parser
stream
- the document stream (input)handler
- handler for the XHTML SAX events (output)metadata
- document metadata (input and output)context
- parse context
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 parsedpublic void parse(java.io.InputStream stream, org.xml.sax.ContentHandler handler, Metadata metadata) throws java.io.IOException, org.xml.sax.SAXException, TikaException
Parser
Parser.parse(InputStream, ContentHandler, Metadata, ParseContext)
method instead in new code. Calls to this backwards compatibility
method are forwarded to the new parse() method with an empty parse
context.
parse
in interface Parser
java.io.IOException
org.xml.sax.SAXException
TikaException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |