adams.flow.source
Class TwitterQuery

java.lang.Object
  extended by adams.core.ConsoleObject
      extended by adams.core.option.AbstractOptionHandler
          extended by adams.flow.core.AbstractActor
              extended by adams.flow.source.AbstractSource
                  extended by adams.flow.source.TwitterQuery
All Implemented Interfaces:
AdditionalInformationHandler, CleanUpHandler, Debuggable, DebugOutputHandler, Destroyable, OptionHandler, QuickInfoSupporter, ShallowCopySupporter<AbstractActor>, SizeOfHandler, Stoppable, VariableChangeListener, Actor, ErrorHandler, OutputProducer, Serializable, Comparable

public class TwitterQuery
extends AbstractSource

Outputs tweet messages.
For more information on twitter queries, see the following web page:
http://search.twitter.com/operators

Input/output:
- generates:
   twitter4j.Status

Valid options are:

-D <int> (property: debugLevel)
    The greater the number the more additional info the scheme may output to 
    the console (0 = off).
    default: 0
    minimum: 0
 
-name <java.lang.String> (property: name)
    The name of the actor.
    default: TwitterQuery
 
-annotation <adams.core.base.BaseText> (property: annotations)
    The annotations to attach to this actor.
    default: 
 
-skip (property: skip)
    If set to true, transformation is skipped and the input token is just forwarded 
    as it is.
 
-stop-flow-on-error (property: stopFlowOnError)
    If set to true, the flow gets stopped in case this actor encounters an error;
     useful for critical actors.
 
-query <java.lang.String> (property: query)
    The query for obtaining the tweets.
    default: search term
 
-results-per-page <int> (property: resultsPerPage)
    The number of results per page when querying twitter.
    default: 20
    minimum: 10
    maximum: 100
 
-max-tweets <int> (property: maxTweets)
    The maximum number of tweets to output.
    default: 100
    minimum: 1
 

Version:
$Revision: 7118 $
Author:
fracpete (fracpete at waikato dot ac dot nz)
See Also:
Serialized Form

Field Summary
protected  int m_Count
          the current count of tweets.
protected  Long m_LastId
          the ID of the last tweet returned.
protected  int m_MaxTweets
          the maximum number of tweets to output.
protected  String m_Query
          the query.
protected  twitter4j.QueryResult m_QueryResult
          the result returned by twitter.
protected  List<twitter4j.Status> m_Queue
          for storing the messages.
protected  int m_ResultsPerPage
          the number of results per page.
protected  twitter4j.Twitter m_Twitter
          for accessing the twitter API.
protected  twitter4j.Query m_TwitterQuery
          for querying the twitter API.
 
Fields inherited from class adams.flow.core.AbstractActor
m_Annotations, m_BackupState, m_DetectedObjectVariables, m_DetectedVariables, m_ErrorHandler, m_Executed, m_Executing, m_ExecutionListeningSupporter, m_FullName, m_Headless, m_Name, m_Parent, m_Root, m_ScopeHandler, m_Self, m_Skip, m_StopFlowOnError, m_StopMessage, m_Stopped, m_StorageHandler, m_VariablesUpdated
 
Fields inherited from class adams.core.option.AbstractOptionHandler
m_DebugLevel, m_OptionManager
 
Fields inherited from interface adams.flow.core.Actor
FILE_EXTENSION, FILE_EXTENSION_GZ
 
Constructor Summary
TwitterQuery()
           
 
Method Summary
 void defineOptions()
          Adds options to the internal list of options.
protected  String doExecute()
          Executes the flow item.
 Class[] generates()
          Returns the class of objects that it generates.
 int getMaxTweets()
          Returns the maximum number of tweets to output.
 String getQuery()
          Returns the twitter query to use.
 String getQuickInfo()
          Returns a quick info about the actor, which will be displayed in the GUI.
 int getResultsPerPage()
          Returns the number of results per page (for each query).
 String globalInfo()
          Returns a string describing the object.
 boolean hasPendingOutput()
          Checks whether there is pending output to be collected after executing the flow item.
protected  void initialize()
          Initializes the members.
 String maxTweetsTipText()
          Returns the tip text for this property.
 Token output()
          Returns the generated token.
protected  void performQuery()
          Obtains a bunch of tweets.
 String queryTipText()
          Returns the tip text for this property.
protected  void reset()
          Resets the scheme.
 String resultsPerPageTipText()
          Returns the tip text for this property.
 void setMaxTweets(int value)
          Sets the maximum number of tweets to output.
 void setQuery(String value)
          Sets the twitter query to use.
 void setResultsPerPage(int value)
          Sets the number of results per page (for each query).
 void stopExecution()
          Stops the execution.
 void wrapUp()
          Cleans up after the execution has finished.
 
Methods inherited from class adams.flow.core.AbstractActor
annotationsTipText, backupState, canInspectOptions, canPerformSetUpCheck, cleanUp, compareTo, debug, destroy, equals, execute, findVariables, findVariables, findVariables, forceVariables, forCommandLine, forName, getAdditionalInformation, getAnnotations, getDefaultName, getDetectedVariables, getErrorHandler, getFlowActors, getFlowExecutionListeningSupporter, getFullName, getName, getNextSibling, getParent, getParentComponent, getPreviousSibling, getRoot, getScopeHandler, getSkip, getStopFlowOnError, getStopMessage, getStorageHandler, getVariables, handleError, handleException, hasErrorHandler, hasStopMessage, index, isBackedUp, isExecuted, isExecuting, isFinished, isHeadless, isStopped, nameTipText, performSetUpChecks, postExecute, preExecute, pruneBackup, pruneBackup, restoreState, setAnnotations, setErrorHandler, setHeadless, setName, setParent, setSkip, setStopFlowOnError, setUp, setVariables, shallowCopy, shallowCopy, sizeOf, skipTipText, stopExecution, stopFlowOnErrorTipText, updateDetectedVariables, updatePrefix, updateVariables, variableChanged
 
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, debug, debugLevelTipText, finishInit, getDebugLevel, getOptionManager, isDebugOn, newOptionManager, setDebugLevel, toCommandLine, toString
 
Methods inherited from class adams.core.ConsoleObject
getDebugging, getSystemErr, getSystemOut
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface adams.flow.core.Actor
cleanUp, compareTo, debug, destroy, equals, execute, findVariables, getAnnotations, getDefaultName, getDetectedVariables, getErrorHandler, getFlowExecutionListeningSupporter, getFullName, getName, getNextSibling, getParent, getParentComponent, getPreviousSibling, getRoot, getScopeHandler, getSkip, getStopFlowOnError, getStopMessage, getStorageHandler, getVariables, handleError, hasErrorHandler, hasStopMessage, index, isExecuted, isFinished, isHeadless, isStopped, setAnnotations, setErrorHandler, setHeadless, setName, setParent, setSkip, setStopFlowOnError, setUp, setVariables, sizeOf, stopExecution, variableChanged
 
Methods inherited from interface adams.core.AdditionalInformationHandler
getAdditionalInformation
 
Methods inherited from interface adams.core.option.OptionHandler
cleanUpOptions, getOptionManager
 

Field Detail

m_Query

protected String m_Query
the query.


m_ResultsPerPage

protected int m_ResultsPerPage
the number of results per page.


m_MaxTweets

protected int m_MaxTweets
the maximum number of tweets to output.


m_Queue

protected List<twitter4j.Status> m_Queue
for storing the messages.


m_Twitter

protected twitter4j.Twitter m_Twitter
for accessing the twitter API.


m_TwitterQuery

protected twitter4j.Query m_TwitterQuery
for querying the twitter API.


m_QueryResult

protected twitter4j.QueryResult m_QueryResult
the result returned by twitter.


m_Count

protected int m_Count
the current count of tweets.


m_LastId

protected Long m_LastId
the ID of the last tweet returned.

Constructor Detail

TwitterQuery

public TwitterQuery()
Method Detail

globalInfo

public String globalInfo()
Returns a string describing the object.

Specified by:
globalInfo in class AbstractOptionHandler
Returns:
a description suitable for displaying in the gui

defineOptions

public void defineOptions()
Adds options to the internal list of options.

Specified by:
defineOptions in interface OptionHandler
Overrides:
defineOptions in class AbstractActor

initialize

protected void initialize()
Initializes the members.

Overrides:
initialize in class AbstractActor

reset

protected void reset()
Resets the scheme.

Overrides:
reset in class AbstractActor

getQuickInfo

public String getQuickInfo()
Returns a quick info about the actor, which will be displayed in the GUI.

Specified by:
getQuickInfo in interface QuickInfoSupporter
Specified by:
getQuickInfo in interface Actor
Overrides:
getQuickInfo in class AbstractActor
Returns:
null if no info available, otherwise short string

generates

public Class[] generates()
Returns the class of objects that it generates.

Returns:
the classes

setQuery

public void setQuery(String value)
Sets the twitter query to use.

Parameters:
value - the query

getQuery

public String getQuery()
Returns the twitter query to use.

Returns:
the query

queryTipText

public String queryTipText()
Returns the tip text for this property.

Returns:
tip text for this property suitable for displaying in the GUI or for listing the options.

setResultsPerPage

public void setResultsPerPage(int value)
Sets the number of results per page (for each query).

Parameters:
value - the maximum number

getResultsPerPage

public int getResultsPerPage()
Returns the number of results per page (for each query).

Returns:
the maximum number

resultsPerPageTipText

public String resultsPerPageTipText()
Returns the tip text for this property.

Returns:
tip text for this property suitable for displaying in the GUI or for listing the options.

setMaxTweets

public void setMaxTweets(int value)
Sets the maximum number of tweets to output.

Parameters:
value - the maximum number

getMaxTweets

public int getMaxTweets()
Returns the maximum number of tweets to output.

Returns:
the maximum number

maxTweetsTipText

public String maxTweetsTipText()
Returns the tip text for this property.

Returns:
tip text for this property suitable for displaying in the GUI or for listing the options.

performQuery

protected void performQuery()
                     throws Exception
Obtains a bunch of tweets.

Throws:
Exception - if twitter query fails

doExecute

protected String doExecute()
Executes the flow item.

Specified by:
doExecute in class AbstractActor
Returns:
always null

output

public Token output()
Returns the generated token.

Returns:
the generated token

hasPendingOutput

public boolean hasPendingOutput()
Checks whether there is pending output to be collected after executing the flow item.

Returns:
true if there is pending output

stopExecution

public void stopExecution()
Stops the execution. No message set.

Specified by:
stopExecution in interface Stoppable
Specified by:
stopExecution in interface Actor
Overrides:
stopExecution in class AbstractActor

wrapUp

public void wrapUp()
Cleans up after the execution has finished.

Specified by:
wrapUp in interface Actor
Overrides:
wrapUp in class AbstractActor


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