twitter4j
Class TwitterStream

java.lang.Object
  extended by twitter4j.TwitterStream
All Implemented Interfaces:
java.io.Serializable

public final class TwitterStream
extends java.lang.Object
implements java.io.Serializable

A java reporesentation of the Twitter Streaming API
Note that this class is NOT compatible with Google App Engine as GAE is not capable of handling requests longer than 30 seconds.

Since:
Twitter4J 2.0.4
Author:
Yusuke Yamamoto - yusuke at mac.com
See Also:
Serialized Form

Field Summary
protected  Authorization auth
           
protected  Configuration conf
           
 
Constructor Summary
TwitterStream()
          Deprecated. use new TwitterStreamFactory.getInstance() instead.
TwitterStream(java.lang.String screenName, java.lang.String password)
          Deprecated. use new TwitterStreamFactory.getInstance() instead.
TwitterStream(java.lang.String screenName, java.lang.String password, StatusListener listener)
          Deprecated. use new TwitterStreamFactory.getInstance() instead.
 
Method Summary
 void cleanup()
           
protected  void ensureAuthorizationEnabled()
           
protected  void ensureBasicEnabled()
           
 boolean equals(java.lang.Object o)
           
 void filter(int count, int[] follow, java.lang.String[] track)
          Start consuming public statuses that match one or more filter predicates.
 void firehose(int count)
          Starts listening on all public statuses.
 Authorization getAuthorization()
          Returns the authorization scheme for this instance.
The returned type will be either of BasicAuthorization, OAuthAuthorization, or NullAuthorization
 StatusStream getFilterStream(int count, int[] follow, java.lang.String[] track)
          Returns public statuses that match one or more filter predicates.
 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.
 int hashCode()
           
 boolean isBasicAuthEnabled()
          tests if the instance is authenticated by Basic
 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)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

conf

protected final Configuration conf

auth

protected Authorization auth
Constructor Detail

TwitterStream

public TwitterStream()
Deprecated. use new TwitterStreamFactory.getInstance() instead.

Constructs a TwitterStream instance. UserID and password should be provided by either twitter4j.properties or system property. since Twitter4J 2.0.10


TwitterStream

public TwitterStream(java.lang.String screenName,
                     java.lang.String password)
Deprecated. use new TwitterStreamFactory.getInstance() instead.

Constructs a TwitterStream instance. UserID and password should be provided by either twitter4j.properties or system property. since Twitter4J 2.0.10

Parameters:
screenName - screen name
password - password

TwitterStream

public TwitterStream(java.lang.String screenName,
                     java.lang.String password,
                     StatusListener listener)
Deprecated. use new TwitterStreamFactory.getInstance() instead.

Constructs a TwitterStream instance. UserID and password should be provided by either twitter4j.properties or system property. since Twitter4J 2.0.10

Parameters:
screenName - screen name
password - password
listener - listener
Method Detail

firehose

public void firehose(int count)
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.
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 of 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

links

public void links(int count)
Starts listening on all public statuses containing links. Available only to approved parties and requires a signed agreement to access. Please do not contact us about access to the links stream. 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.
Since:
Twitter4J 2.1.1
See Also:
StatusStream, Twitter API Wiki / Streaming API Documentation - links

getLinksStream

public StatusStream getLinksStream(int count)
                            throws TwitterException
Returns a status stream of all public statuses containing links. Available only to approved parties and requires a signed agreement to access. Please do not contact us about access to the links stream. 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.1.1
See Also:
StatusStream, Twitter API Wiki / Streaming API Documentation - links

retweet

public void retweet()
Starts listening on all retweets. The retweet stream is not a generally available resource. Few applications require this level of access. Creative use of a combination of other resources and various access levels can satisfy nearly every application use case. As of 9/11/2009, the site-wide retweet feature has not yet launched, so there are currently few, if any, retweets on this stream.

Since:
Twitter4J 2.0.10
See Also:
StatusStream, Twitter API Wiki / Streaming API Documentation - retweet

getRetweetStream

public StatusStream getRetweetStream()
                              throws TwitterException
Returns a stream of all retweets. The retweet stream is not a generally available resource. Few applications require this level of access. Creative use of a combination of other resources and various access levels can satisfy nearly every application use case. As of 9/11/2009, the site-wide retweet feature has not yet launched, so there are currently few, if any, retweets on this stream.

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

sample

public void sample()
Starts listening on random sample of all public statuses. The default access level provides a small proportion of the Firehose. The "Gardenhose" access level provides a proportion more suitable for data mining and research applications that desire a larger proportion to be statistically significant sample.

Since:
Twitter4J 2.0.10
See Also:
StatusStream, Twitter API Wiki / Streaming API Documentation - sample

getSampleStream

public StatusStream getSampleStream()
                             throws TwitterException
Returns a stream of random sample of all public statuses. The default access level provides a small proportion of the Firehose. The "Gardenhose" access level provides a proportion more suitable for data mining and research applications that desire a larger proportion to be statistically significant sample.

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

filter

public void filter(int count,
                   int[] follow,
                   java.lang.String[] track)
Start consuming public statuses that match one or more filter predicates. At least one predicate parameter, follow, locations, or track must be specified. Multiple parameters may be specified which allows most clients to use a single connection to the Streaming API. Placing long parameters in the URL may cause the request to be rejected for excessive URL length.
The default access level allows up to 200 track keywords, 400 follow userids and 10 1-degree location boxes. Increased access levels allow 80,000 follow userids ("shadow" role), 400,000 follow userids ("birddog" role), 10,000 track keywords ("restricted track" role), 200,000 track keywords ("partner track" role), and 200 10-degree location boxes ("locRestricted" role). Increased track access levels also pass a higher proportion of statuses before limiting the stream.

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.
track - Specifies keywords to track.
Since:
Twitter4J 2.0.10
See Also:
StatusStream, Twitter API Wiki / Streaming API Documentation - filter

getFilterStream

public StatusStream getFilterStream(int count,
                                    int[] follow,
                                    java.lang.String[] track)
                             throws TwitterException
Returns public statuses that match one or more filter predicates. At least one predicate parameter, follow, locations, or track must be specified. Multiple parameters may be specified which allows most clients to use a single connection to the Streaming API. Placing long parameters in the URL may cause the request to be rejected for excessive URL length.
The default access level allows up to 200 track keywords, 400 follow userids and 10 1-degree location boxes. Increased access levels allow 80,000 follow userids ("shadow" role), 400,000 follow userids ("birddog" role), 10,000 track keywords ("restricted track" role), 200,000 track keywords ("partner track" role), and 200 10-degree location boxes ("locRestricted" role). Increased track access levels also pass a higher proportion of statuses before limiting the stream.

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.10
See Also:
StatusStream, Twitter API Wiki / Streaming API Documentation - filter

cleanup

public void cleanup()

setStatusListener

public void setStatusListener(StatusListener statusListener)

isBasicAuthEnabled

public final boolean isBasicAuthEnabled()
tests if the instance is authenticated by Basic

Returns:
returns true if the instance is authenticated by Basic

ensureAuthorizationEnabled

protected final void ensureAuthorizationEnabled()

ensureBasicEnabled

protected final void ensureBasicEnabled()

getAuthorization

public final Authorization getAuthorization()
Returns the authorization scheme for this instance.
The returned type will be either of BasicAuthorization, OAuthAuthorization, or NullAuthorization

Returns:
the authorization scheme for this instance

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

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


Copyright © 2010. All Rights Reserved.