Package tweetoscope.tweetsFilter
Class CountryCodeTweetFilter
java.lang.Object
tweetoscope.tweetsFilter.TweetFilter
tweetoscope.tweetsFilter.OnlineTweetFilter
tweetoscope.tweetsFilter.CountryCodeTweetFilter
- All Implemented Interfaces:
Flow.Publisher<com.twitter.clientlib.model.Tweet>
,Flow.Subscriber<com.twitter.clientlib.model.Tweet>
Filters Tweets according to their country code
- Author:
- Virginie Galtier
-
Field Summary
Fields inherited from class tweetoscope.tweetsFilter.OnlineTweetFilter
BEARER_TOKEN, twitterApiInstance
Fields inherited from class tweetoscope.tweetsFilter.TweetFilter
subscribers
-
Constructor Summary
ConstructorDescriptionCountryCodeTweetFilter
(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. -
Method Summary
Modifier and TypeMethodDescriptionprotected String
getCountryCode
(com.twitter.clientlib.model.Tweet tweet) Returns the country code of the place tagged in a Tweet, if any.protected boolean
match
(com.twitter.clientlib.model.Tweet tweet) Tests the filter conditionsMethods inherited from class tweetoscope.tweetsFilter.TweetFilter
onComplete, onError, onNext, onSubscribe, subscribe
-
Field Details
-
countryCode
The targeted country code to match
-
-
Constructor Details
-
CountryCodeTweetFilter
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 classTweetFilter
- Parameters:
tweet
- Tweet to examine- Returns:
- true if the Tweet complies with the filter, false if it doesn't match the filter conditions
-
getCountryCode
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
-