Class TweetFilter

java.lang.Object
tweetoscope.tweetsFilter.TweetFilter
All Implemented Interfaces:
Flow.Publisher<com.twitter.clientlib.model.Tweet>, Flow.Subscriber<com.twitter.clientlib.model.Tweet>
Direct Known Subclasses:
EmptyTweetFilter, LangTweetFilter, LastNTweetFilter, OnlineTweetFilter

public abstract class TweetFilter extends Object implements Flow.Subscriber<com.twitter.clientlib.model.Tweet>, Flow.Publisher<com.twitter.clientlib.model.Tweet>
Reacts to the reception of a new Tweet, if the Tweet matches the filter condition, downstream subscribers are notified, otherwise the process is silent. Tweets are received from
invalid reference
distributed_tweetoscope.tweetsProducer.TweetsProducer
via Java Flow. Filtered Tweets are passes down to the
invalid reference
distributed_tweetoscope.HashtagCounter
via Java Flow.
Author:
Virginie Galtier
  • Field Details

    • subscribers

      protected List<Flow.Subscriber<? super com.twitter.clientlib.model.Tweet>> subscribers
      List of objects to notify when a new Tweet passes the filter (downstream component = HashtagExtractor)
  • Constructor Details

    • TweetFilter

      public TweetFilter()
      Creates a new Tweet filter
  • Method Details

    • match

      protected abstract boolean match(com.twitter.clientlib.model.Tweet tweet)
      Tests the filter conditions
      Parameters:
      tweet - Tweet to examine
      Returns:
      true if the Tweet complies with the filter, false if it doesn't match the filter conditions
    • subscribe

      public void subscribe(Flow.Subscriber<? super com.twitter.clientlib.model.Tweet> subscriber)
      Specified by:
      subscribe in interface Flow.Publisher<com.twitter.clientlib.model.Tweet>
    • onNext

      public void onNext(com.twitter.clientlib.model.Tweet tweet)
      Specified by:
      onNext in interface Flow.Subscriber<com.twitter.clientlib.model.Tweet>
    • onSubscribe

      public void onSubscribe(Flow.Subscription subscription)
      Specified by:
      onSubscribe in interface Flow.Subscriber<com.twitter.clientlib.model.Tweet>
    • onError

      public void onError(Throwable throwable)
      Specified by:
      onError in interface Flow.Subscriber<com.twitter.clientlib.model.Tweet>
    • onComplete

      public void onComplete()
      Specified by:
      onComplete in interface Flow.Subscriber<com.twitter.clientlib.model.Tweet>