Class CountryCodeTweetFilter

All Implemented Interfaces:
Flow.Publisher<com.twitter.clientlib.model.Tweet>, Flow.Subscriber<com.twitter.clientlib.model.Tweet>

public class CountryCodeTweetFilter extends OnlineTweetFilter
Filters Tweets according to their country code
Author:
Virginie Galtier
  • Field Details

    • countryCode

      protected String countryCode
      The targeted country code to match
  • Constructor Details

    • CountryCodeTweetFilter

      public CountryCodeTweetFilter(String countryCode)
      Creates a filter that queries the Twitter API to retrieve the country code associated with the "place" tag of a Tweet (if it is set) and tests whether its value equals a given code.
      Parameters:
      countryCode - targeted country code to match (example: "us")
  • Method Details

    • match

      protected boolean match(com.twitter.clientlib.model.Tweet tweet)
      Description copied from class: TweetFilter
      Tests the filter conditions
      Specified by:
      match in class TweetFilter
      Parameters:
      tweet - Tweet to examine
      Returns:
      true if the Tweet complies with the filter, false if it doesn't match the filter conditions
    • getCountryCode

      protected String getCountryCode(com.twitter.clientlib.model.Tweet tweet)
      Returns the country code of the place tagged in a Tweet, if any. Version 1: manually, provided as an example
      Parameters:
      tweet -
      Returns:
      the country code of the place tagged in a Tweet if the information is available, null otherwise