twitter4j
Class TwitterStream

java.lang.Object
  extended by twitter4j.TwitterSupport
      extended by twitter4j.TwitterStream

public class TwitterStream
extends TwitterSupport

A java reporesentation of the Twitter Streaming API

Since:
Twitter4J 2.0.4
Author:
Yusuke Yamamoto - yusuke at mac.com

Nested Class Summary
(package private)  class TwitterStream.StreamHandlingThread
           
 
Field Summary
private static boolean DEBUG
           
private  TwitterStream.StreamHandlingThread handler
           
private  int retryPerMinutes
           
private  StatusListener statusListener
           
private static java.lang.String STREAM_BASE_URL
           
 
Fields inherited from class twitter4j.TwitterSupport
http, source
 
Constructor Summary
TwitterStream(java.lang.String userId, java.lang.String password)
           
TwitterStream(java.lang.String userId, java.lang.String password, StatusListener listener)
           
 
Method Summary
 void birddog(int count, int[] follow)
          Starts listening on public statuses from a specified set of users, by ID.
 void cleanup()
           
 void firehose(int count)
          Starts listening on all public statuses.
 void follow(int[] follow)
          See birddog above.
 void gardenhose()
          Starts listening on a percentage of all public statuses, suitable for data mining and research applications that require a statistically significant sample.
 StatusStream getBirddogStream(int count, int[] follow)
          Returns a status stream for public statuses from a specified set of users, by ID.
 StatusStream getFirehoseStream(int count)
          Returns a status stream for all public statuses.
 StatusStream getFollowStream(int[] follow)
          See birddog above.
 StatusStream getGardenhoseStream()
          Returns a status stream for a percentage of all public statuses, suitable for data mining and research applications that require a statistically significant sample.
 StatusStream getShadowStream(int count, int[] follow)
          See birddog above.
 StatusStream getSpritzerStream()
          Returns a status stream for a percentage of all public statuses, suitable for small projects that don't require a statistically significant sample.
 StatusListener getStatusListener()
           
private  void log(java.lang.String message)
           
private  void log(java.lang.String message, java.lang.String message2)
           
 void setStatusListener(StatusListener statusListener)
           
 void shadow(int count, int[] follow)
          See birddog above.
 void spritzer()
          Starts listening on a percentage of all public statuses, suitable for small projects that don't require a statistically significant sample.
private  void startHandler(TwitterStream.StreamHandlingThread handler)
           
private  java.lang.String toFollowString(int[] follows)
           
 
Methods inherited from class twitter4j.TwitterSupport
forceUsePost, getClientURL, getClientVersion, getPassword, getSource, getUserAgent, getUserId, isUsePostForced, setClientURL, setClientVersion, setHttpConnectionTimeout, setHttpProxy, setHttpProxyAuth, setHttpReadTimeout, setPassword, setRequestHeader, setRetryCount, setRetryIntervalSecs, setSource, setUserAgent, setUserId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

private static final boolean DEBUG

STREAM_BASE_URL

private static final java.lang.String STREAM_BASE_URL
See Also:
Constant Field Values

statusListener

private StatusListener statusListener

handler

private TwitterStream.StreamHandlingThread handler

retryPerMinutes

private int retryPerMinutes
Constructor Detail

TwitterStream

public TwitterStream(java.lang.String userId,
                     java.lang.String password)

TwitterStream

public TwitterStream(java.lang.String userId,
                     java.lang.String password,
                     StatusListener listener)
Method Detail

firehose

public void firehose(int count)
              throws TwitterException
Starts listening on all public statuses. Available only to approved parties and requires a signed agreement to access. Please do not contact us about access to the firehose. If your service warrants access to it, we'll contact you.

Parameters:
count - Indicates the number of previous statuses to stream before transitioning to the live stream.
Throws:
TwitterException - when Twitter service or network is unavailable
Since:
Twitter4J 2.0.4
See Also:
StatusStream, Twitter API Wiki / Streaming API Documentation - firehose

getFirehoseStream

public StatusStream getFirehoseStream(int count)
                               throws TwitterException
Returns a status stream for all public statuses. Available only to approved parties and requires a signed agreement to access. Please do not contact us about access to the firehose. If your service warrants access to it, we'll contact you.

Parameters:
count - Indicates the number of previous statuses to stream before transitioning to the live stream.
Returns:
StatusStream
Throws:
TwitterException - when Twitter service or network is unavailable
Since:
Twitter4J 2.0.4
See Also:
StatusStream, Twitter API Wiki / Streaming API Documentation - firehose

gardenhose

public void gardenhose()
                throws TwitterException
Starts listening on a percentage of all public statuses, suitable for data mining and research applications that require a statistically significant sample. Available only to approved parties and requires a signed agreement to access.

Throws:
TwitterException - when Twitter service or network is unavailable
Since:
Twitter4J 2.0.4
See Also:
StatusStream, Twitter API Wiki / Streaming API Documentation - gardenhose

getGardenhoseStream

public StatusStream getGardenhoseStream()
                                 throws TwitterException
Returns a status stream for a percentage of all public statuses, suitable for data mining and research applications that require a statistically significant sample. Available only to approved parties and requires a signed agreement to access.

Returns:
StatusStream
Throws:
TwitterException - when Twitter service or network is unavailable
Since:
Twitter4J 2.0.4
See Also:
StatusStream, Twitter API Wiki / Streaming API Documentation - gardenhose

spritzer

public void spritzer()
              throws TwitterException
Starts listening on a percentage of all public statuses, suitable for small projects that don't require a statistically significant sample. Publicly available.

Throws:
TwitterException - when Twitter service or network is unavailable
Since:
Twitter4J 2.0.4
See Also:
StatusStream, Twitter API Wiki / Streaming API Documentation - spritizer

getSpritzerStream

public StatusStream getSpritzerStream()
                               throws TwitterException
Returns a status stream for a percentage of all public statuses, suitable for small projects that don't require a statistically significant sample. Publicly available.

Returns:
StatusStream
Throws:
TwitterException - when Twitter service or network is unavailable
Since:
Twitter4J 2.0.4
See Also:
StatusStream, Twitter API Wiki / Streaming API Documentation - spritizer

birddog

public void birddog(int count,
                    int[] follow)
             throws TwitterException
Starts listening on public statuses from a specified set of users, by ID. Requires use of the "follow" parameter, documented below. Allows following up to 200,000 users. Available only to approved parties and requires a signed agreement to access.

Parameters:
count - 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.
Throws:
TwitterException - when Twitter service or network is unavailable
Since:
Twitter4J 2.0.4
See Also:
StatusStream, Twitter API Wiki / Streaming API Documentation - birddog

getBirddogStream

public StatusStream getBirddogStream(int count,
                                     int[] follow)
                              throws TwitterException
Returns a status stream for public statuses from a specified set of users, by ID. Requires use of the "follow" parameter, documented below. Allows following up to 200,000 users. Available only to approved parties and requires a signed agreement to access.

Parameters:
count - 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.
Returns:
StatusStream
Throws:
TwitterException - when Twitter service or network is unavailable
Since:
Twitter4J 2.0.4
See Also:
StatusStream, Twitter API Wiki / Streaming API Documentation - birddog

shadow

public void shadow(int count,
                   int[] follow)
            throws TwitterException
See birddog above. Allows following up to 2,000 users.

Parameters:
count - 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.
Throws:
TwitterException - when Twitter service or network is unavailable
Since:
Twitter4J 2.0.4
See Also:
StatusStream, Twitter API Wiki / Streaming API Documentation - shadow

getShadowStream

public StatusStream getShadowStream(int count,
                                    int[] follow)
                             throws TwitterException
See birddog above. Allows following up to 2,000 users.

Parameters:
count - 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.
Returns:
StatusStream
Throws:
TwitterException - when Twitter service or network is unavailable
Since:
Twitter4J 2.0.4
See Also:
StatusStream, Twitter API Wiki / Streaming API Documentation - shadow

follow

public void follow(int[] follow)
            throws TwitterException
See birddog above. Allows following up to 200 users. Publicly available.

Parameters:
follow - Specifies the users, by ID, to receive public tweets from.
Throws:
TwitterException - when Twitter service or network is unavailable
Since:
Twitter4J 2.0.4
See Also:
StatusStream, Twitter API Wiki / Streaming API Documentation - follow

getFollowStream

public StatusStream getFollowStream(int[] follow)
                             throws TwitterException
See birddog above. Allows following up to 200 users. Publicly available.

Parameters:
follow - Specifies the users, by ID, to receive public tweets from.
Returns:
StatusStream
Throws:
TwitterException - when Twitter service or network is unavailable
Since:
Twitter4J 2.0.4
See Also:
StatusStream, Twitter API Wiki / Streaming API Documentation - follow

toFollowString

private java.lang.String toFollowString(int[] follows)

startHandler

private void startHandler(TwitterStream.StreamHandlingThread handler)
                   throws TwitterException
Throws:
TwitterException

cleanup

public void cleanup()

getStatusListener

public StatusListener getStatusListener()

setStatusListener

public void setStatusListener(StatusListener statusListener)

log

private void log(java.lang.String message)

log

private void log(java.lang.String message,
                 java.lang.String message2)