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
FieldsModifier and TypeFieldDescriptionprotected final List<IEventListener>protected final List<IEventFilter[]> -
Constructor Summary
ConstructorsConstructorDescriptionConstructs aFilteredEventListenerempty instance.FilteredEventListener(IEventListener delegate, IEventFilter... filterSet) Constructs aFilteredEventListenerinstance with one delegate. -
Method Summary
Modifier and TypeMethodDescriptionIEventListener>
TattachEventListener(T delegate, IEventFilter... filterSet) Attaches anotherIEventListenerdelegate with its filters.voideventOccurred(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 aFilteredEventListenerempty instance. UseattachEventListener(IEventListener, IEventFilter...)to add an event listener along with its filters. -
FilteredEventListener
Constructs aFilteredEventListenerinstance with one delegate. UseattachEventListener(IEventListener, IEventFilter...)to add moreIEventListenerdelegates 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 anotherIEventListenerdelegate 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 thisFilteredEventListenerinstance. The content stream will be parsed just once, so it is better for performance than creating multipleFilteredEventListenerinstances 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:IEventListenerCalled when some event occurs during parsing a content stream.- Specified by:
-
eventOccurredin interfaceIEventListener - Parameters:
-
data- Combines the data required for processing corresponding event type. -
type- Event type.
-
getSupportedEvents
Description copied from interface:IEventListenerProvides the set of event types this listener supports. Returns null if all possible event types are supported.- Specified by:
-
getSupportedEventsin interfaceIEventListener - Returns:
- Set of event types supported by this listener or null if all possible event types are supported.
-