Class FilteredEventListener

All Implemented Interfaces:
Direct Known Subclasses:

public class FilteredEventListener extends Object implements IEventListener
An event listener which filters events on the fly before passing them on to the delegate.
  • Field Details

  • Constructor Details

  • Method Details

    • attachEventListener

      public IEventListener> T attachEventListener (T delegate, IEventFilter... filterSet)
      Attaches another IEventListener 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 this FilteredEventListener instance. The content stream will be parsed just once, so it is better for performance than creating multiple FilteredEventListener 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
      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
      delegate that has been passed to the method, used for convenient call chaining
    • eventOccurred

      public void eventOccurred (IEventData data, EventType type)
      Description copied from interface: IEventListener
      Called when some event occurs during parsing a content stream.
      Specified by:
      eventOccurred in interface IEventListener
      data - Combines the data required for processing corresponding event type.
      type - Event type.
    • getSupportedEvents

      public Set<EventType> 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 interface IEventListener
      Set of event types supported by this listener or null if all possible event types are supported.