Package twitter4j

Examples of twitter4j.QueryResult


    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        QueryResult that = (QueryResult) o;

        if (Double.compare(that.getCompletedIn(), completedIn) != 0)
            return false;
        if (maxId != that.getMaxId()) return false;
        if (page != that.getPage()) return false;
        if (resultsPerPage != that.getResultsPerPage()) return false;
        if (sinceId != that.getSinceId()) return false;
        if (!query.equals(that.getQuery())) return false;
        if (refreshUrl != null ? !refreshUrl.equals(that.getRefreshUrl()) : that.getRefreshUrl() != null)
            return false;
        if (tweets != null ? !tweets.equals(that.getTweets()) : that.getTweets() != null)
            return false;
        if (warning != null ? !warning.equals(that.getWarning()) : that.getWarning() != null)
            return false;

        return true;
    }
View Full Code Here


            if (page > 0)
                query.setMaxId(maxId);

            query.setPage(page + 1);
            query.setRpp(hitsPerPage);
            QueryResult res = twitter.search(query);

            // is res.getTweets() sorted?
            for (Object o : res.getTweets()) {
                Tweet twe = (Tweet) o;
                // determine maxId in the first page
                if (page == 0 && maxId < twe.getId())
                    maxId = twe.getId();

                if (maxMillis < twe.getCreatedAt().getTime())
                    maxMillis = twe.getCreatedAt().getTime();

                if (twe.getCreatedAt().getTime() + 1000 < lastMaxCreateTime)
                    breakPaging = true;
                else {
                    String userName = twe.getFromUser().toLowerCase();
                    JUser user = userMap.get(userName);
                    if (user == null) {
                        user = new JUser(userName).init(twe);
                        userMap.put(userName, user);
                    }

                    result.add(new JTweet(twe, user));
                }
            }

            // minMillis could force us to leave earlier than defined by maxPages
            // or if resulting tweets are less then request (but -10 because of twitter strangeness)
            if (breakPaging || res.getTweets().size() < hitsPerPage - 10)
                break;
        }

        return maxMillis;
    }
View Full Code Here

        }
       
        LOG.debug("Searching with " + numberOfPages + " pages.");

        Twitter twitter = te.getProperties().getTwitter();
        QueryResult qr = twitter.search(query);
        List<Status> tweets = qr.getTweets();

        for (int i = 1; i < numberOfPages; i++) {
            if (!qr.hasNext()) {
                break;
            }

            qr = twitter.search(qr.nextQuery());
            tweets.addAll(qr.getTweets());
        }

        if (te.getProperties().isFilterOld()) {
            for (Status t : tweets) {
                checkLastId(t.getId());
View Full Code Here

  public void start(BundleContext context) throws Exception {
    Twitter twitter = new Twitter();
    Query query = new Query("from:theasf");
   
    try {
      QueryResult result = twitter.search(query);
        List<Tweet> tweets = result.getTweets();
        System.out.println("hits:" + tweets.size());
        for (Tweet tweet : result.getTweets()) {
            System.out.println(tweet.getFromUser() + ":" + StringEscapeUtils.unescapeXml(tweet.getText()));
        }
    } catch (Exception e) {
      e.printStackTrace();
    }
View Full Code Here

        if (null != geo) {
            GeoLocation loc = new GeoLocation(geo.getLatitude(), geo.getLongitude());
            query.setGeoCode(loc, geo.getRadius(), Query.KILOMETERS);
        }

        QueryResult result = null;

        do {
            query = null == result ? query : result.nextQuery();
            try {
                LOGGER.info("requesting search results");
                result = twitter.search(query);
            } catch (TwitterException e) {
                throw new TwitterClientException(e);
            }

            for (Status status : result.getTweets()) {
                if (!handler.isOpen()) {
                    LOGGER.info("handler closed");
                    return;
                }

                handler.handle(new Tweet(status));
            }
            if (result.hasNext()) {
                System.out.println("there are more results!");
            } else {
                System.out.println("no more results");
            }
        } while (result.hasNext());
    }
View Full Code Here

  {
      // The factory instance is re-useable and thread safe.
      twitter = new TwitterFactory().getInstance();
     
      Query query = new Query("CLOUD JBOSS");
      QueryResult result;
    try {
      result = twitter.search(query);
      System.out.println("hits:" + result.getCompletedIn());
          for (Tweet tweet : result.getTweets()) {
              System.out.println(tweet.getFromUser() + ":" + tweet.getText());
          }
    } catch (TwitterException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
View Full Code Here

        }
       
        LOG.debug("Searching with " + numberOfPages + " pages.");

        Twitter twitter = te.getProperties().getTwitter();
        QueryResult qr = twitter.search(query);
        List<Status> tweets = qr.getTweets();

        for (int i = 1; i < numberOfPages; i++) {
            if (!qr.hasNext()) {
                break;
            }

            qr = twitter.search(qr.nextQuery());
            tweets.addAll(qr.getTweets());
        }

        if (te.getProperties().isFilterOld()) {
            for (Status t : tweets) {
                checkLastId(t.getId());
View Full Code Here

TOP

Related Classes of twitter4j.QueryResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.