Class AbstractListener
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.flow.source.twitterlistener.AbstractListener
-
- All Implemented Interfaces:
adams.core.Destroyable
,adams.core.GlobalInfoSupporter
,adams.core.logging.LoggingLevelHandler
,adams.core.logging.LoggingSupporter
,adams.core.option.OptionHandler
,adams.core.Pausable
,adams.core.QuickInfoSupporter
,adams.core.SizeOfHandler
,adams.core.Stoppable
,adams.flow.core.FlowContextHandler
,Serializable
- Direct Known Subclasses:
SampleListener
,UserListener
public abstract class AbstractListener extends adams.core.option.AbstractOptionHandler implements adams.core.Pausable, adams.core.Stoppable, adams.core.QuickInfoSupporter, adams.flow.core.FlowContextHandler
Ancestor for twitter stream listeners.- Version:
- $Revision: 13567 $
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected int
m_Count
the counter for tweets.protected adams.flow.core.Actor
m_FlowContext
the owner.protected boolean
m_Listening
whether the listener is running.protected int
m_MaxStatusUpdates
the maximum number of status updates to output.protected twitter4j.Status
m_Next
the next available Status.protected boolean
m_Paused
the listener is paused.protected twitter4j.TwitterStream
m_Twitter
for accessing the twitter streaming API.
-
Constructor Summary
Constructors Constructor Description AbstractListener()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
defineOptions()
Adds options to the internal list of options.adams.flow.core.Actor
getFlowContext()
Returns the flow context.adams.core.logging.Logger
getLogger()
Returns the logger in use.int
getMaxStatusUpdates()
Returns the maximum number of status updates to output.String
getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.boolean
hasNext()
Returns whether there is another update available.protected void
initialize()
Initializes the members.boolean
isListening()
Returns whether the listener is active.boolean
isPaused()
Returns whether the object is currently paused.String
maxStatusUpdatesTipText()
Returns the tip text for this property.twitter4j.Status
next()
Retrieves the next status update.void
pauseExecution()
Pauses the execution (if still listening).protected abstract void
removeListener()
Removes the listener.void
resumeExecution()
Resumes the execution.void
setFlowContext(adams.flow.core.Actor value)
Sets the flow context.void
setMaxStatusUpdates(int value)
Sets the maximum number of status updates to output.abstract void
startExecution()
Starts the listening.void
stopExecution()
Stops the execution.-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, globalInfo, loggingLevelTipText, newOptionManager, reset, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
-
-
-
Field Detail
-
m_MaxStatusUpdates
protected int m_MaxStatusUpdates
the maximum number of status updates to output.
-
m_FlowContext
protected adams.flow.core.Actor m_FlowContext
the owner.
-
m_Twitter
protected transient twitter4j.TwitterStream m_Twitter
for accessing the twitter streaming API.
-
m_Count
protected int m_Count
the counter for tweets.
-
m_Next
protected twitter4j.Status m_Next
the next available Status.
-
m_Paused
protected boolean m_Paused
the listener is paused.
-
m_Listening
protected boolean m_Listening
whether the listener is running.
-
-
Method Detail
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initialize
in classadams.core.option.AbstractOptionHandler
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptions
in interfaceadams.core.option.OptionHandler
- Overrides:
defineOptions
in classadams.core.option.AbstractOptionHandler
-
setMaxStatusUpdates
public void setMaxStatusUpdates(int value)
Sets the maximum number of status updates to output.- Parameters:
value
- the maximum number
-
getMaxStatusUpdates
public int getMaxStatusUpdates()
Returns the maximum number of status updates to output.- Returns:
- the maximum number
-
maxStatusUpdatesTipText
public String maxStatusUpdatesTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getQuickInfo
public String getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.- Specified by:
getQuickInfo
in interfaceadams.core.QuickInfoSupporter
- Returns:
- null if no info available, otherwise short string
-
getLogger
public adams.core.logging.Logger getLogger()
Returns the logger in use.- Specified by:
getLogger
in interfaceadams.core.logging.LoggingSupporter
- Overrides:
getLogger
in classadams.core.logging.LoggingObject
- Returns:
- the logger
-
setFlowContext
public void setFlowContext(adams.flow.core.Actor value)
Sets the flow context.- Specified by:
setFlowContext
in interfaceadams.flow.core.FlowContextHandler
- Parameters:
value
- the flow context
-
getFlowContext
public adams.flow.core.Actor getFlowContext()
Returns the flow context.- Specified by:
getFlowContext
in interfaceadams.flow.core.FlowContextHandler
- Returns:
- the flow context
-
startExecution
public abstract void startExecution()
Starts the listening.
-
isListening
public boolean isListening()
Returns whether the listener is active.- Returns:
- true if active
-
pauseExecution
public void pauseExecution()
Pauses the execution (if still listening).- Specified by:
pauseExecution
in interfaceadams.core.Pausable
-
isPaused
public boolean isPaused()
Returns whether the object is currently paused.- Specified by:
isPaused
in interfaceadams.core.Pausable
- Returns:
- true if object is paused
-
resumeExecution
public void resumeExecution()
Resumes the execution.- Specified by:
resumeExecution
in interfaceadams.core.Pausable
-
removeListener
protected abstract void removeListener()
Removes the listener.
-
stopExecution
public void stopExecution()
Stops the execution.- Specified by:
stopExecution
in interfaceadams.core.Stoppable
-
hasNext
public boolean hasNext()
Returns whether there is another update available.- Returns:
- true if another update available
-
next
public twitter4j.Status next()
Retrieves the next status update.- Returns:
- the next status
-
-