public static void run ( VicariousFactory factory ) { // Get the tweets TweetProvider provider = factory . getTweetProvider ( ) ; List < Status > originals = null ; try { originals = provider . getTweets ( ) ; if ( originals == null || originals . isEmpty ( ) ) { return ; } } catch ( TwitterException exception ) { exception . printStackTrace ( ) ; return ; } // Sort the tweets from oldest to newest Comparator < Status > comparator = new TweetDateComparator ( ) ; Collections . sort ( originals , comparator ) ; // Modify the tweets TweetModifier modifier = factory . getTweetModifier ( ) ; List < TweetPair > tweetPairs = new ArrayList < TweetPair > ( ) ; for ( Status original : originals ) { StatusUpdate response = modifier . modify ( original ) ; if ( response != null ) { tweetPairs . add ( new TweetPair ( original , response ) ) ; } } // Publish the tweets TweetPublisher publisher = factory . getTweetPublisher ( ) ; TweetLogger logger = factory . getTweetLogger ( ) ; try { if ( logger == null ) { for ( TweetPair tweetPair : tweetPairs ) { publisher . publish ( tweetPair . response ) ; } } else { for ( TweetPair tweetPair : tweetPairs ) { publisher . publish ( tweetPair . response , new LoggingListener ( logger , tweetPair . original ) ) ; } } } catch ( TwitterException exception ) { exception . printStackTrace ( ) ; return ; } }
Runs a single iteration of the provide modify publish loop using the implementations provided by the given factory