public class ParserDecorator extends AbstractParser
Parser
interface. This class
simply delegates all parsing calls to an underlying decorated parser
instance. Subclasses can provide extra decoration by overriding the
parse method.Constructor and Description |
---|
ParserDecorator(Parser parser)
Creates a decorator for the given parser.
|
Modifier and Type | Method and Description |
---|---|
Set<MediaType> |
getSupportedTypes(ParseContext context)
Delegates the method call to the decorated parser.
|
Parser |
getWrappedParser()
Gets the parser wrapped by this ParserDecorator
|
void |
parse(InputStream stream,
ContentHandler handler,
Metadata metadata,
ParseContext context)
Delegates the method call to the decorated parser.
|
static Parser |
withFallbacks(Collection<? extends Parser> parsers,
Set<MediaType> types)
Deprecated.
Do not use until the TODOs are resolved, see TIKA-1509
|
static Parser |
withoutTypes(Parser parser,
Set<MediaType> excludeTypes)
Decorates the given parser so that it never claims to support
parsing of the given media types, but will work for all others.
|
static Parser |
withTypes(Parser parser,
Set<MediaType> types)
Decorates the given parser so that it always claims to support
parsing of the given media types.
|
parse
public ParserDecorator(Parser parser)
parser
- the parser instance to be decoratedpublic static final Parser withTypes(Parser parser, Set<MediaType> types)
parser
- the parser to be decoratedtypes
- supported media typespublic static final Parser withoutTypes(Parser parser, Set<MediaType> excludeTypes)
parser
- the parser to be decoratedtypes
- excluded/ignored media typespublic static final Parser withFallbacks(Collection<? extends Parser> parsers, Set<MediaType> types)
public Set<MediaType> getSupportedTypes(ParseContext context)
super.getSupportedTypes()
to invoke the decorated parser) to implement extra decoration.context
- parse contextpublic void parse(InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, SAXException, TikaException
super.parse()
to invoke
the decorated parser) to implement extra decoration.stream
- the document stream (input)handler
- handler for the XHTML SAX events (output)metadata
- document metadata (input and output)context
- parse contextIOException
- if the document stream could not be readSAXException
- if the SAX events could not be processedTikaException
- if the document could not be parsedpublic Parser getWrappedParser()
Copyright © 2007-2015 The Apache Software Foundation. All Rights Reserved.