public final class TwitterStream extends TwitterOAuthSupportBaseImpl implements java.io.Serializable
Modifier and Type | Class and Description |
---|---|
(package private) class |
TwitterStream.StreamHandlingThread |
Modifier and Type | Field and Description |
---|---|
private TwitterStream.StreamHandlingThread |
handler |
private twitter4j.internal.http.HttpClientWrapper |
http |
private static int |
HTTP_ERROR_INITIAL_WAIT |
private static int |
HTTP_ERROR_WAIT_CAP |
private java.util.List<ConnectionLifeCycleListener> |
lifeCycleListeners |
private static twitter4j.internal.logging.Logger |
logger |
private static int |
NO_WAIT |
private static long |
serialVersionUID |
private java.util.List<StatusListener> |
statusListeners |
private static int |
TCP_ERROR_INITIAL_WAIT |
private static int |
TCP_ERROR_WAIT_CAP |
id, screenName
rateLimitStatusListener
auth, conf
Constructor and Description |
---|
TwitterStream()
Deprecated.
use
TwitterStreamFactory.getInstance() instead. |
TwitterStream(Configuration conf,
Authorization auth,
StatusListener listener) |
TwitterStream(java.lang.String screenName,
java.lang.String password)
Deprecated.
use
TwitterStreamFactory.getInstance() instead. |
TwitterStream(java.lang.String screenName,
java.lang.String password,
StatusListener listener)
Deprecated.
use
TwitterStreamFactory.getInstance() instead. |
Modifier and Type | Method and Description |
---|---|
void |
addConnectionLifeCycleListener(ConnectionLifeCycleListener listener)
Adds a ConnectionLifeCycleListener
|
void |
addStatusListener(StatusListener statusListener) |
void |
addUserStreamListener(UserStreamListener userStreamListener) |
void |
cleanup()
Deprecated.
use #cleanUp instead
|
void |
cleanUp()
shutdown internal stream consuming thread
|
void |
filter(FilterQuery query)
Start consuming public statuses that match one or more filter predicates.
|
void |
filter(int count,
int[] follow,
java.lang.String[] track)
Deprecated.
use
filter(FilterQuery) instead |
void |
firehose(int count)
Starts listening on all public statuses.
|
private StatusStream |
getCountStream(java.lang.String relativeUrl,
int count) |
StatusStream |
getFilterStream(FilterQuery query)
Returns public statuses that match one or more filter predicates.
|
StatusStream |
getFilterStream(int count,
int[] follow,
java.lang.String[] track)
Deprecated.
use
getFilterStream(FilterQuery) instead |
StatusStream |
getFirehoseStream(int count)
Returns a status stream of all public statuses.
|
StatusStream |
getLinksStream(int count)
Returns a status stream of all public statuses containing links.
|
StatusStream |
getRetweetStream()
Returns a stream of all retweets.
|
StatusStream |
getSampleStream()
Returns a stream of random sample of all public statuses.
|
UserStream |
getUserStream()
User Streams provides real-time updates of all data needed to update a desktop application display.
|
void |
links(int count)
Starts listening on all public statuses containing links.
|
void |
retweet()
Starts listening on all retweets.
|
void |
sample()
Starts listening on random sample of all public statuses.
|
void |
setStatusListener(StatusListener statusListener)
Deprecated.
use #addStatusListener instead.
|
void |
setUserStreamListener(UserStreamListener userStreamListener)
Deprecated.
use #addStatusListener instead
|
private void |
startHandler(TwitterStream.StreamHandlingThread handler) |
private void |
startUserStreamHandler(TwitterStream.StreamHandlingThread handler) |
void |
stream(java.lang.String relativeUrl,
int count,
boolean handleUserStream)
Starts listening on a tweet stream.
|
void |
user()
User Streams provides real-time updates of all data needed to update a desktop application display.
|
getOAuthAccessToken, getOAuthAccessToken, getOAuthAccessToken, getOAuthAccessToken, getOAuthAccessToken, getOAuthAccessToken, getOAuthRequestToken, getOAuthRequestToken, isOAuthEnabled, setOAuthAccessToken, setOAuthAccessToken, setOAuthConsumer
equals, hashCode, httpResponseReceived, setRateLimitStatusListener, shutdown
ensureAuthorizationEnabled, ensureBasicEnabled, getAuthorization, isBasicAuthEnabled, toString
private final twitter4j.internal.http.HttpClientWrapper http
private static final twitter4j.internal.logging.Logger logger
private java.util.List<StatusListener> statusListeners
private java.util.List<ConnectionLifeCycleListener> lifeCycleListeners
private TwitterStream.StreamHandlingThread handler
private static final long serialVersionUID
private static final int TCP_ERROR_INITIAL_WAIT
private static final int TCP_ERROR_WAIT_CAP
private static final int HTTP_ERROR_INITIAL_WAIT
private static final int HTTP_ERROR_WAIT_CAP
private static final int NO_WAIT
public TwitterStream()
TwitterStreamFactory.getInstance()
instead.public TwitterStream(java.lang.String screenName, java.lang.String password)
TwitterStreamFactory.getInstance()
instead.screenName
- screen namepassword
- passwordpublic TwitterStream(java.lang.String screenName, java.lang.String password, StatusListener listener)
TwitterStreamFactory.getInstance()
instead.screenName
- screen namepassword
- passwordlistener
- listenerTwitterStream(Configuration conf, Authorization auth, StatusListener listener)
public void firehose(int count)
count
- Indicates the number of previous statuses to stream before transitioning to the live stream.StatusStream
,
Streaming API: Methods statuses/firehosepublic StatusStream getFirehoseStream(int count) throws TwitterException
count
- Indicates the number of previous statuses to stream before transitioning to the live stream.TwitterException
- when Twitter service or network is unavailableStatusStream
,
Streaming API: Methods statuses/firehosepublic void links(int count)
count
- Indicates the number of previous statuses to stream before transitioning to the live stream.StatusStream
,
Streaming API: Methods statuses/linkspublic StatusStream getLinksStream(int count) throws TwitterException
count
- Indicates the number of previous statuses to stream before transitioning to the live stream.TwitterException
- when Twitter service or network is unavailableStatusStream
,
Streaming API: Methods statuses/linkspublic void stream(java.lang.String relativeUrl, int count, boolean handleUserStream)
relativeUrl
- The relative url of the feed, for example "statuses/firehose.json" for the firehose.count
- Indicates the number of previous statuses to stream before transitioning to the live stream.private StatusStream getCountStream(java.lang.String relativeUrl, int count) throws TwitterException
TwitterException
public void retweet()
StatusStream
,
Streaming API: Methods statuses/retweetpublic StatusStream getRetweetStream() throws TwitterException
TwitterException
- when Twitter service or network is unavailableStatusStream
,
Streaming API: Methods statuses/retweetpublic void sample()
StatusStream
,
Streaming API: Methods statuses/samplepublic StatusStream getSampleStream() throws TwitterException
TwitterException
- when Twitter service or network is unavailableStatusStream
,
Streaming API: Methods statuses/samplepublic void user()
public UserStream getUserStream() throws TwitterException
TwitterException
- when Twitter service or network is unavailablepublic void filter(FilterQuery query) throws TwitterException
query
- Filter queryTwitterException
StatusStream
,
Streaming API: Methods statuses/filterpublic StatusStream getFilterStream(FilterQuery query) throws TwitterException
query
- Filter queryTwitterException
- when Twitter service or network is unavailableStatusStream
,
Twitter API Wiki / Streaming API Documentation - filterpublic void filter(int count, int[] follow, java.lang.String[] track)
filter(FilterQuery)
insteadcount
- Indicates the number of previous statuses to stream before transitioning to the live stream.follow
- Specifies the users, by ID, to receive public tweets from.track
- Specifies keywords to track.StatusStream
,
Twitter API Wiki / Streaming API Documentation - filterpublic StatusStream getFilterStream(int count, int[] follow, java.lang.String[] track) throws TwitterException
getFilterStream(FilterQuery)
insteadfollow
- Specifies the users, by ID, to receive public tweets from.TwitterException
- when Twitter service or network is unavailableStatusStream
,
Twitter API Wiki / Streaming API Documentation - filterprivate void startHandler(TwitterStream.StreamHandlingThread handler)
private void startUserStreamHandler(TwitterStream.StreamHandlingThread handler)
public void cleanUp()
public void cleanup()
public void setStatusListener(StatusListener statusListener)
statusListener
- listener to be setpublic void addStatusListener(StatusListener statusListener)
statusListener
- listener to be addedpublic void addConnectionLifeCycleListener(ConnectionLifeCycleListener listener)
listener
- listener to be addedpublic void setUserStreamListener(UserStreamListener userStreamListener)
userStreamListener
- listener to be setpublic void addUserStreamListener(UserStreamListener userStreamListener)
userStreamListener
- listener to be added