adams.flow.source
Class TwitterListener.Listener

java.lang.Object
  extended by java.lang.Thread
      extended by adams.flow.source.TwitterListener.Listener
All Implemented Interfaces:
Runnable, twitter4j.StatusListener
Enclosing class:
TwitterListener

public static class TwitterListener.Listener
extends Thread
implements twitter4j.StatusListener

Thread for listening to Twitter status updates.

Version:
$Revision: 4584 $
Author:
fracpete (fracpete at waikato dot ac dot nz)

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
static int HTTP_ERROR_INITIAL_WAIT
           
static int HTTP_ERROR_WAIT_CAP
           
protected  int m_Count
          the number of status received so far.
protected  boolean m_Listening
          whether the thread is still listening for updates.
protected  twitter4j.Status m_Next
          the next status update.
protected  TwitterListener m_Owner
          the owning actor.
protected  twitter4j.StatusStream m_Stream
          the status stream.
protected  int m_TimeToSleep
          the time to sleep for the thread.
protected  twitter4j.TwitterStream m_Twitter
          for accessing the twitter streaming API.
protected  twitter4j.StatusListener m_TwitterListener
          for listening to tweets.
static int TCP_ERROR_INITIAL_WAIT
           
static int TCP_ERROR_WAIT_CAP
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
TwitterListener.Listener(TwitterListener owner)
          Initializes the listener thread.
 
Method Summary
 TwitterListener getOwner()
          Returns the owning actor.
 boolean hasNext()
          Returns whether there is another update available.
 boolean isListening()
          Returns whether the thread is still listening.
 twitter4j.Status next()
          Returns the next status update.
 void onDeletionNotice(twitter4j.StatusDeletionNotice arg0)
          Ignored.
 void onException(Exception e)
          Whenever an exception occurs.
 void onScrubGeo(int arg0, long arg1)
          Ignored.
 void onStatus(twitter4j.Status status)
          Reacts to new updates.
 void onTrackLimitationNotice(int arg0)
          Ignored.
 void run()
          Starts the listening.
 void stopListening()
          Stops the listening process.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TCP_ERROR_INITIAL_WAIT

public static final int TCP_ERROR_INITIAL_WAIT
See Also:
Constant Field Values

TCP_ERROR_WAIT_CAP

public static final int TCP_ERROR_WAIT_CAP
See Also:
Constant Field Values

HTTP_ERROR_INITIAL_WAIT

public static final int HTTP_ERROR_INITIAL_WAIT
See Also:
Constant Field Values

HTTP_ERROR_WAIT_CAP

public static final int HTTP_ERROR_WAIT_CAP
See Also:
Constant Field Values

m_Owner

protected TwitterListener m_Owner
the owning actor.


m_Twitter

protected twitter4j.TwitterStream m_Twitter
for accessing the twitter streaming API.


m_TwitterListener

protected twitter4j.StatusListener m_TwitterListener
for listening to tweets.


m_Listening

protected boolean m_Listening
whether the thread is still listening for updates.


m_Count

protected int m_Count
the number of status received so far.


m_Stream

protected twitter4j.StatusStream m_Stream
the status stream.


m_TimeToSleep

protected int m_TimeToSleep
the time to sleep for the thread.


m_Next

protected twitter4j.Status m_Next
the next status update.

Constructor Detail

TwitterListener.Listener

public TwitterListener.Listener(TwitterListener owner)
Initializes the listener thread.

Parameters:
owner - the owning actor
Method Detail

getOwner

public TwitterListener getOwner()
Returns the owning actor.

Returns:
the owner

run

public void run()
Starts the listening.

Specified by:
run in interface Runnable
Overrides:
run in class Thread

isListening

public boolean isListening()
Returns whether the thread is still listening.

Returns:
true if listening

stopListening

public void stopListening()
Stops the listening process.


onDeletionNotice

public void onDeletionNotice(twitter4j.StatusDeletionNotice arg0)
Ignored.

Specified by:
onDeletionNotice in interface twitter4j.StatusListener
Parameters:
arg0 - ignored

onException

public void onException(Exception e)
Whenever an exception occurs. Merely outputs the exception.

Parameters:
e - the execption

onStatus

public void onStatus(twitter4j.Status status)
Reacts to new updates.

Specified by:
onStatus in interface twitter4j.StatusListener
Parameters:
status - the new update

onTrackLimitationNotice

public void onTrackLimitationNotice(int arg0)
Ignored.

Specified by:
onTrackLimitationNotice in interface twitter4j.StatusListener
Parameters:
arg0 - ignored

onScrubGeo

public void onScrubGeo(int arg0,
                       long arg1)
Ignored.

Specified by:
onScrubGeo in interface twitter4j.StatusListener
Parameters:
arg0 - ignored
arg1 - ignored

next

public twitter4j.Status next()
Returns the next status update.

Returns:
the update

hasNext

public boolean hasNext()
Returns whether there is another update available.

Returns:
true if another update available


Copyright © 2012 University of Waikato, Hamilton, NZ. All Rights Reserved.