winterwell.jtwitter
Class TwitterStream

java.lang.Object
  extended by winterwell.jtwitter.AStream
      extended by winterwell.jtwitter.TwitterStream
All Implemented Interfaces:
java.io.Closeable

public class TwitterStream
extends AStream

Connect to the streaming API.

Duplicate messages may be delivered when reconnecting to the Streaming API.


Nested Class Summary
static class TwitterStream.KMethod
           
 
Nested classes/interfaces inherited from class winterwell.jtwitter.AStream
AStream.IListen, AStream.Outage
 
Field Summary
 
Fields inherited from class winterwell.jtwitter.AStream
MAX_BUFFER
 
Constructor Summary
TwitterStream(Twitter jtwit)
           
 
Method Summary
 java.util.List<java.lang.String> getTrackKeywords()
           
 void setFollowUsers(java.util.List<java.lang.Long> userIds)
           
 void setListenersOnly(boolean listenersOnly)
          default: false If true, json is only sent to listeners, and polling based access via AStream.getTweets() will return no results.
 void setLocation(java.util.List<double[]> boundingBoxes)
          Deprecated. 
 void setTrackKeywords(java.util.List<java.lang.String> keywords)
          See https://dev.twitter.com/docs/streaming-api/methods#track
 java.lang.String toString()
           
 
Methods inherited from class winterwell.jtwitter.AStream
addListener, addOutage, clear, close, connect, fillInOutages, finalize, getEvents, getForgotten, getOutages, getSystemEvents, getTweets, isAlive, isConnected, popEvents, popSystemEvents, popTweets, removeListener, setAutoReconnect, setPreviousCount
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TwitterStream

public TwitterStream(Twitter jtwit)
Parameters:
client - This will have it's timeout set to 90 seconds. So you probably don't want to reuse the object with the REST api.
Method Detail

getTrackKeywords

public java.util.List<java.lang.String> getTrackKeywords()

setFollowUsers

public void setFollowUsers(java.util.List<java.lang.Long> userIds)
Parameters:
userIds - Upto 5,000 userids to follow

setLocation

@Deprecated
public void setLocation(java.util.List<double[]> boundingBoxes)
Deprecated. 

TODO This is not implemented yet! 25 0.1-360 degree location boxes. Only tweets that are both created using the Geotagging API and are placed from within a tracked bounding box will be included in the stream – the user’s location field is not used to filter tweets

Parameters:
boundingBoxes - Each element consists of longitude/latitude south-west, north-east.

setTrackKeywords

public void setTrackKeywords(java.util.List<java.lang.String> keywords)
See https://dev.twitter.com/docs/streaming-api/methods#track

Terms are exact-matched, and also exact-matched ignoring punctuation. Each term may be up to 60 characters long.

Exact matching on phrases, that is, keywords with spaces, is not supported. Keywords containing punctuation will only exact match tokens and, other than keywords prefixed by # and @, will tend to never match. Non-space separated languages, such as CJK and Arabic, are currently unsupported as tokenization only occurs on whitespace and punctuation. Other UTF-8 phrases should exact match correctly, but will not substitute similar characters to their least-common-denominator. For all these cases, consider falling back to the Search REST API.

Parameters:
keywords - The default access level allows up to 400 track keywords. You can also do phrases, separating words with a space.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

setListenersOnly

public void setListenersOnly(boolean listenersOnly)
default: false If true, json is only sent to listeners, and polling based access via AStream.getTweets() will return no results.

See Also:
AStream.addListener(IListen)