class TwitterStreamImpl extends TwitterBaseImpl implements TwitterStream
| Modifier and Type | Class and Description |
|---|---|
(package private) static class |
TwitterStreamImpl.Mode |
(package private) class |
TwitterStreamImpl.TwitterStreamConsumer |
| Modifier and Type | Field and Description |
|---|---|
private static int |
count |
private static Dispatcher |
dispatcher |
private TwitterStreamImpl.TwitterStreamConsumer |
handler |
private HttpClient |
http |
private static int |
HTTP_ERROR_INITIAL_WAIT |
private static int |
HTTP_ERROR_WAIT_CAP |
private java.util.List<ConnectionLifeCycleListener> |
lifeCycleListeners |
private static Logger |
logger |
private static int |
NO_WAIT |
private static int |
numberOfHandlers |
private static long |
serialVersionUID |
private java.lang.String |
stallWarningsGetParam |
private HttpParameter |
stallWarningsParam |
private java.util.ArrayList<StreamListener> |
streamListeners |
private static int |
TCP_ERROR_INITIAL_WAIT |
private static int |
TCP_ERROR_WAIT_CAP |
auth, conf, factory| Constructor and Description |
|---|
TwitterStreamImpl(Configuration conf,
Authorization auth) |
| Modifier and Type | Method and Description |
|---|---|
TwitterStream |
addConnectionLifeCycleListener(ConnectionLifeCycleListener listener)
Adds a ConnectionLifeCycleListener
|
TwitterStream |
addListener(StreamListener listener) |
TwitterStream |
cleanUp()
shutdown internal stream consuming thread
|
TwitterStream |
clearListeners()
clear status listeners
|
private void |
ensureSiteStreamsListenerIsSet() |
private void |
ensureStatusStreamListenerIsSet()
check if any listener is set.
|
boolean |
equals(java.lang.Object o) |
TwitterStream |
filter(FilterQuery query)
Start consuming public statuses that match one or more filter predicates.
|
TwitterStream |
filter(java.lang.String... track)
Start consuming public statuses that match the filter predicate.
|
TwitterStream |
firehose(int count)
Starts listening on all public statuses.
|
private StatusStream |
getCountStream(java.lang.String relativeUrl,
int count) |
private Dispatcher |
getDispatcher() |
(package private) StatusStream |
getFilterStream(FilterQuery query)
Returns public statuses that match one or more filter predicates.
|
(package private) StatusStream |
getFirehoseStream(int count)
Returns a status stream of all public statuses.
|
(package private) StatusStream |
getLinksStream(int count)
Returns a status stream of all public statuses containing links.
|
private RawStreamListener[] |
getRawStreamListeners() |
(package private) StatusStream |
getRetweetStream()
Returns a stream of all retweets.
|
(package private) StatusStream |
getSampleStream()
Returns a stream of random sample of all public statuses.
|
(package private) StatusStream |
getSampleStream(java.lang.String language)
Returns a stream of random sample of all public statuses.
|
(package private) java.io.InputStream |
getSiteStream(boolean withFollowings,
long[] follow) |
private SiteStreamsListener[] |
getSiteStreamsListeners() |
private StatusListener[] |
getStatusListeners() |
(package private) UserStream |
getUserStream(java.lang.String[] track)
User Streams provides real-time updates of all data needed to update a desktop application display.
|
int |
hashCode() |
TwitterStream |
links(int count)
Starts listening on all public statuses containing links.
|
TwitterStream |
onException(Consumer<java.lang.Exception> action) |
TwitterStream |
onStatus(Consumer<Status> action) |
TwitterStream |
removeListener(StreamListener listener) |
TwitterStream |
replaceListener(StreamListener toBeRemoved,
StreamListener toBeAdded)
replace existing listener
|
TwitterStream |
retweet()
Starts listening on all retweets.
|
TwitterStream |
sample()
Starts listening on random sample of all public statuses.
|
TwitterStream |
sample(java.lang.String language)
Starts listening on random sample of all public statuses.
|
TwitterStream |
shutdown()
Shuts down internal dispatcher thread shared by all TwitterStream instances.
|
StreamController |
site(boolean withFollowings,
long[] follow)
Site Streams, a new feature on the Streaming API, is now available for beta testing.
|
private void |
startHandler(TwitterStreamImpl.TwitterStreamConsumer handler) |
java.lang.String |
toString() |
private void |
updateListeners() |
TwitterStream |
user()
User Streams provides real-time updates of all data needed to update a desktop application display.
|
TwitterStream |
user(java.lang.String[] track)
User Streams provides real-time updates of all data needed to update a desktop application display.
|
addRateLimitStatusListener, ensureAuthorizationEnabled, ensureOAuthEnabled, fillInIDAndScreenName, fillInIDAndScreenName, getAuthorization, getConfiguration, getId, getOAuth2Token, getOAuthAccessToken, getOAuthAccessToken, getOAuthAccessToken, getOAuthAccessToken, getOAuthAccessToken, getOAuthRequestToken, getOAuthRequestToken, getOAuthRequestToken, getOAuthRequestToken, getScreenName, httpResponseReceived, invalidateOAuth2Token, onRateLimitReached, onRateLimitStatus, setFactory, setOAuth2Token, setOAuthAccessToken, setOAuthConsumerclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetOAuthAccessToken, getOAuthAccessToken, getOAuthAccessToken, getOAuthAccessToken, getOAuthAccessToken, getOAuthRequestToken, getOAuthRequestToken, getOAuthRequestToken, getOAuthRequestToken, setOAuthAccessToken, setOAuthConsumeraddRateLimitStatusListener, getAuthorization, getConfiguration, getId, getScreenName, onRateLimitReached, onRateLimitStatusprivate static final long serialVersionUID
private final HttpClient http
private static final Logger logger
private final java.util.List<ConnectionLifeCycleListener> lifeCycleListeners
private TwitterStreamImpl.TwitterStreamConsumer handler
private final java.lang.String stallWarningsGetParam
private final HttpParameter stallWarningsParam
private static transient volatile Dispatcher dispatcher
private static int numberOfHandlers
private final java.util.ArrayList<StreamListener> streamListeners
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
private static int count
TwitterStreamImpl(Configuration conf, Authorization auth)
public TwitterStream firehose(int count)
TwitterStreamfirehose in interface TwitterStreamcount - Indicates the number of previous statuses to stream before transitioning to the live stream.StatusStream,
Streaming API Methods statuses/firehoseStatusStream 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 TwitterStream links(int count)
TwitterStreamlinks in interface TwitterStreamcount - Indicates the number of previous statuses to stream before transitioning to the live stream.StatusStream,
Streaming API Methods statuses/linksStatusStream 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/linksprivate StatusStream getCountStream(java.lang.String relativeUrl, int count) throws TwitterException
TwitterExceptionpublic TwitterStream retweet()
TwitterStreamretweet in interface TwitterStreamStatusStream,
Streaming API Methods statuses/retweetStatusStream getRetweetStream() throws TwitterException
TwitterException - when Twitter service or network is unavailableStatusStream,
Streaming API: Methods statuses/retweetpublic TwitterStream sample()
TwitterStreamsample in interface TwitterStreamStatusStream,
Streaming API: Methods statuses/samplepublic TwitterStream sample(java.lang.String language)
TwitterStreamOnly samples Tweets written in the given language.
sample in interface TwitterStreamlanguage - language to be sampledStatusStream,
Streaming API: Methods statuses/sampleStatusStream getSampleStream() throws TwitterException
TwitterException - when Twitter service or network is unavailableStatusStream,
Streaming API: Methods statuses/sampleStatusStream getSampleStream(java.lang.String language) throws TwitterException
Only returns tweets in the given languages
TwitterException - when Twitter service or network is unavailableStatusStream,
Streaming API: Methods statuses/samplepublic TwitterStream user()
TwitterStreamuser in interface TwitterStreampublic TwitterStream user(java.lang.String[] track)
TwitterStreamuser in interface TwitterStreamtrack - keywords to trackUserStream getUserStream(java.lang.String[] track) throws TwitterException
track - keywords to trackTwitterException - when Twitter service or network is unavailablepublic StreamController site(boolean withFollowings, long[] follow)
TwitterStreamsite in interface TwitterStreamwithFollowings - whether to receive status updates from people followingfollow - an array of users to include in the streamprivate Dispatcher getDispatcher()
java.io.InputStream getSiteStream(boolean withFollowings,
long[] follow)
throws TwitterException
TwitterExceptionpublic TwitterStream filter(FilterQuery query)
TwitterStreamfilter in interface TwitterStreamquery - Filter queryStatusStream,
Streaming API Methods statuses/filterpublic TwitterStream filter(java.lang.String... track)
TwitterStreamfilter in interface TwitterStreamtrack - words to be filteredStatusStream getFilterStream(FilterQuery query) throws TwitterException
query - Filter queryTwitterException - when Twitter service or network is unavailableStatusStream,
Streaming API Methods | Twitter Developersprivate void ensureStatusStreamListenerIsSet()
java.lang.IllegalStateException - when no listener is set.private void ensureSiteStreamsListenerIsSet()
private void startHandler(TwitterStreamImpl.TwitterStreamConsumer handler)
public TwitterStream cleanUp()
TwitterStreamcleanUp in interface TwitterStreampublic TwitterStream shutdown()
TwitterStreamshutdown in interface TwitterStreampublic TwitterStream addConnectionLifeCycleListener(ConnectionLifeCycleListener listener)
TwitterStreamaddConnectionLifeCycleListener in interface TwitterStreamlistener - listener to be addedpublic TwitterStream addListener(StreamListener listener)
addListener in interface TwitterStreamlistener - listener to addpublic TwitterStream onStatus(Consumer<Status> action)
onStatus in interface TwitterStreamaction - action when receiving Statuspublic TwitterStream onException(Consumer<java.lang.Exception> action)
onException in interface TwitterStreamaction - action when receiving TwitterExceptionpublic TwitterStream removeListener(StreamListener listener)
removeListener in interface TwitterStreamlistener - listener to removepublic TwitterStream clearListeners()
TwitterStreamclearListeners in interface TwitterStreampublic TwitterStream replaceListener(StreamListener toBeRemoved, StreamListener toBeAdded)
TwitterStreamreplaceListener in interface TwitterStreamtoBeRemoved - listener to be removedtoBeAdded - listener to be addedprivate void updateListeners()
private RawStreamListener[] getRawStreamListeners()
private SiteStreamsListener[] getSiteStreamsListeners()
private StatusListener[] getStatusListeners()
public boolean equals(java.lang.Object o)
equals in class TwitterBaseImplpublic int hashCode()
hashCode in class TwitterBaseImplpublic java.lang.String toString()
toString in class TwitterBaseImpl