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.
To decorate several different parsers at the same time, wrap them in
a CompositeParser
instance first.
Constructor and Description |
---|
ParserDecorator(Parser parser)
Creates a decorator for the given parser.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getDecorationName() |
java.util.Set<MediaType> |
getSupportedTypes(ParseContext context)
Delegates the method call to the decorated parser.
|
Parser |
getWrappedParser()
Gets the parser wrapped by this ParserDecorator
|
void |
parse(java.io.InputStream stream,
org.xml.sax.ContentHandler handler,
Metadata metadata,
ParseContext context)
Delegates the method call to the decorated parser.
|
static Parser |
withFallbacks(java.util.Collection<? extends Parser> parsers,
java.util.Set<MediaType> types)
Deprecated.
Do not use until the TODOs are resolved, see TIKA-1509
|
static Parser |
withoutTypes(Parser parser,
java.util.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,
java.util.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, java.util.Set<MediaType> types)
parser
- the parser to be decoratedtypes
- supported media typespublic static final Parser withoutTypes(Parser parser, java.util.Set<MediaType> excludeTypes)
parser
- the parser to be decoratedexcludeTypes
- excluded/ignored media typespublic static final Parser withFallbacks(java.util.Collection<? extends Parser> parsers, java.util.Set<MediaType> types)
public java.util.Set<MediaType> getSupportedTypes(ParseContext context)
super.getSupportedTypes()
to invoke the decorated parser) to implement extra decoration.context
- parse contextpublic void parse(java.io.InputStream stream, org.xml.sax.ContentHandler handler, Metadata metadata, ParseContext context) throws java.io.IOException, org.xml.sax.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 contextjava.io.IOException
- if the document stream could not be readorg.xml.sax.SAXException
- if the SAX events could not be processedTikaException
- if the document could not be parsedpublic java.lang.String getDecorationName()
public Parser getWrappedParser()
Copyright © 2010 - 2020 Adobe. All Rights Reserved