Class FilteredEventListener
java.lang.Object
com.itextpdf.kernel.pdf.canvas.parser.listener.FilteredEventListener
- All Implemented Interfaces:
-
IEventListener
- Direct Known Subclasses:
-
FilteredTextEventListener
An event listener which filters events on the fly before passing them on to the delegate.
-
Field Summary
Modifier and TypeFieldDescriptionprotected final List<IEventListener>
protected final List<IEventFilter[]>
-
Constructor Summary
ConstructorDescriptionConstructs aFilteredEventListener
empty instance.FilteredEventListener
(IEventListener delegate, IEventFilter... filterSet) Constructs aFilteredEventListener
instance with one delegate. -
Method Summary
Modifier and TypeMethodDescriptionIEventListener>
TattachEventListener
(T delegate, IEventFilter... filterSet) Attaches anotherIEventListener
delegate with its filters.void
eventOccurred
(IEventData data, EventType type) Called when some event occurs during parsing a content stream.Provides the set of event types this listener supports.
-
Field Details
-
delegates
-
filters
-
-
Constructor Details
-
FilteredEventListener
public FilteredEventListener()Constructs aFilteredEventListener
empty instance. UseattachEventListener(IEventListener, IEventFilter...)
to add an event listener along with its filters. -
FilteredEventListener
Constructs aFilteredEventListener
instance with one delegate. UseattachEventListener(IEventListener, IEventFilter...)
to add moreIEventListener
delegates along with their filters.- Parameters:
-
delegate
- a delegate that will be called when all the corresponding filters for an event pass -
filterSet
- filters attached to the delegate that will be tested before passing an event on to the delegate
-
-
Method Details
-
attachEventListener
Attaches anotherIEventListener
delegate with its filters. When all the filters attached to the delegate for an event accept the event, the event will be passed on to the delegate. You can attach multiple delegates to thisFilteredEventListener
instance. The content stream will be parsed just once, so it is better for performance than creating multipleFilteredEventListener
instances and parsing the content stream multiple times. This is useful, for instance, when you want to extract content from multiple regions of a page.- Type Parameters:
-
T
- the type of the delegate - Parameters:
-
delegate
- a delegate that will be called when all the corresponding filters for an event pass -
filterSet
- filters attached to the delegate that will be tested before passing an event on to the delegate - Returns:
- delegate that has been passed to the method, used for convenient call chaining
-
eventOccurred
Description copied from interface:IEventListener
Called when some event occurs during parsing a content stream.- Specified by:
-
eventOccurred
in interfaceIEventListener
- Parameters:
-
data
- Combines the data required for processing corresponding event type. -
type
- Event type.
-
getSupportedEvents
Description copied from interface:IEventListener
Provides the set of event types this listener supports. Returns null if all possible event types are supported.- Specified by:
-
getSupportedEvents
in interfaceIEventListener
- Returns:
- Set of event types supported by this listener or null if all possible event types are supported.
-