Example usage for twitter4j Status getText

List of usage examples for twitter4j Status getText

Introduction

In this page you can find the example usage for twitter4j Status getText.

Prototype

String getText();

Source Link

Document

Returns the text of the status

Usage

From source file:com.raythos.sentilexo.twitter.domain.QueryResultItemMapper.java

License:Apache License

public static Map getFieldsMapFromStatus(String queryOwner, String queryName, String queryString,
        Status status) {

    if (queryName != null)
        queryName = queryName.toLowerCase();
    if (queryOwner != null)
        queryOwner = queryOwner.toLowerCase();
    Map m = StatusArraysHelper.getUserMentionMap(status);
    Map newMap = new HashMap();
    for (Object key : m.keySet()) {
        newMap.put(key.toString(), (Long) m.get(key));
    }/*from w w  w . j  a v  a 2  s .  c o m*/
    Double longitude = null;
    Double lattitude = null;
    if (status.getGeoLocation() != null) {
        longitude = status.getGeoLocation().getLongitude();
        lattitude = status.getGeoLocation().getLatitude();
    }
    String place = null;
    if (status.getPlace() != null) {
        place = status.getPlace().getFullName();
    }

    boolean isRetweet = status.getRetweetedStatus() != null;
    Long retweetedId = null;
    String retweetedText = null;
    if (isRetweet) {
        retweetedId = status.getRetweetedStatus().getId();
        retweetedText = status.getRetweetedStatus().getText();
    }

    Map<String, Object> result = new HashMap<>();
    result.put(QueryResultItemFieldNames.STATUS_ID, status.getId());
    result.put(QueryResultItemFieldNames.CREATED_AT, status.getCreatedAt());
    result.put(QueryResultItemFieldNames.CURRENT_USER_RETWEET_ID, status.getCurrentUserRetweetId());
    result.put(QueryResultItemFieldNames.FAVOURITE_COUNT, status.getFavoriteCount());
    result.put(QueryResultItemFieldNames.FAVOURITED, status.isFavorited());
    result.put(QueryResultItemFieldNames.HASHTAGS, StatusArraysHelper.getHashTagsList(status));
    result.put(QueryResultItemFieldNames.IN_REPLY_TO_SCREEN_NAME, (status.getInReplyToScreenName()));
    result.put(QueryResultItemFieldNames.IN_REPLY_TO_STATUS_ID, status.getInReplyToStatusId());
    result.put(QueryResultItemFieldNames.IN_REPLY_TO_USER_ID, status.getInReplyToUserId());
    result.put(QueryResultItemFieldNames.LATITUDE, lattitude);
    result.put(QueryResultItemFieldNames.LONGITUDE, longitude);
    result.put(QueryResultItemFieldNames.MENTIONS, newMap);
    result.put(QueryResultItemFieldNames.LANGUAGE, status.getLang());
    result.put(QueryResultItemFieldNames.PLACE, place);
    result.put(QueryResultItemFieldNames.POSSIBLY_SENSITIVE, status.isPossiblySensitive());
    result.put(QueryResultItemFieldNames.QUERY_NAME, queryName);
    result.put(QueryResultItemFieldNames.QUERY_OWNER, queryOwner);
    result.put(QueryResultItemFieldNames.QUERY, queryString);
    result.put(QueryResultItemFieldNames.RELEVANT_QUERY_TERMS,
            TwitterUtils.relevantQueryTermsFromStatus(queryString, status));
    result.put(QueryResultItemFieldNames.RETWEET, isRetweet);
    result.put(QueryResultItemFieldNames.RETWEET_COUNT, status.getRetweetCount());
    result.put(QueryResultItemFieldNames.RETWEETED, status.isRetweeted());
    result.put(QueryResultItemFieldNames.RETWEETED_BY_ME, status.isRetweetedByMe());
    result.put(QueryResultItemFieldNames.RETWEET_STATUS_ID, retweetedId);
    result.put(QueryResultItemFieldNames.RETWEETED_TEXT, retweetedText);
    result.put(QueryResultItemFieldNames.SCOPES, StatusArraysHelper.getScopesList(status));
    result.put(QueryResultItemFieldNames.SCREEN_NAME, status.getUser().getScreenName());
    result.put(QueryResultItemFieldNames.SOURCE, (status.getSource()));
    result.put(QueryResultItemFieldNames.TEXT, (status.getText()));
    result.put(QueryResultItemFieldNames.TRUNCATED, status.isTruncated());
    result.put(QueryResultItemFieldNames.URLS, StatusArraysHelper.getUrlsList(status));
    result.put(QueryResultItemFieldNames.USER_ID, status.getUser().getId());
    result.put(QueryResultItemFieldNames.USER_NAME, (status.getUser().getName()));
    result.put(QueryResultItemFieldNames.USER_DESCRIPTION, (status.getUser().getDescription()));
    result.put(QueryResultItemFieldNames.USER_LOCATION, (status.getUser().getLocation()));
    result.put(QueryResultItemFieldNames.USER_URL, (status.getUser().getURL()));
    result.put(QueryResultItemFieldNames.USER_IS_PROTECTED, status.getUser().isProtected());
    result.put(QueryResultItemFieldNames.USER_FOLLOWERS_COUNT, status.getUser().getFollowersCount());
    result.put(QueryResultItemFieldNames.USER_CREATED_AT, status.getUser().getCreatedAt());
    result.put(QueryResultItemFieldNames.USER_FRIENDS_COUNT, status.getUser().getFriendsCount());
    result.put(QueryResultItemFieldNames.USER_LISTED_COUNT, status.getUser().getListedCount());
    result.put(QueryResultItemFieldNames.USER_STATUSES_COUNT, status.getUser().getStatusesCount());
    result.put(QueryResultItemFieldNames.USER_FAVOURITES_COUNT, status.getUser().getFavouritesCount());
    return result;
}

From source file:com.raythos.sentilexo.twitter.domain.QueryResultItemMapper.java

License:Apache License

public static TwitterQueryResultItemAvro mapItem(String queryOwner, String queryName, String queryString,
        Status status) {
    TwitterQueryResultItemAvro result = new TwitterQueryResultItemAvro();

    if (queryName != null)
        queryName = queryName.toLowerCase();
    if (queryOwner != null)
        queryOwner = queryOwner.toLowerCase();

    result.setQueryName(queryName);//  w w w  .  ja  v  a 2 s.  co m
    result.setQueryOwner(queryOwner);
    result.setQuery(queryString);
    result.setStatusId(status.getId());
    result.setText(status.getText());

    result.setRelevantQueryTerms(TwitterUtils.relevantQueryTermsFromStatus(queryString, status));
    result.setLang(status.getLang());

    result.setCreatedAt(status.getCreatedAt().getTime());

    User user = status.getUser();
    result.setUserId(user.getId());
    result.setScreenName(user.getScreenName());
    result.setUserLocation(user.getLocation());
    result.setUserName(user.getName());
    result.setUserDescription(user.getDescription());
    result.setUserIsProtected(user.isProtected());
    result.setUserFollowersCount(user.getFollowersCount());
    result.setUserCreatedAt(user.getCreatedAt().getTime());
    result.setUserCreatedAtAsString(DateTimeUtils.getDateAsText(user.getCreatedAt()));
    result.setCreatedAtAsString(DateTimeUtils.getDateAsText(status.getCreatedAt()));
    result.setUserFriendsCount(user.getFriendsCount());
    result.setUserListedCount(user.getListedCount());
    result.setUserStatusesCount(user.getStatusesCount());
    result.setUserFavoritesCount(user.getFavouritesCount());

    result.setCurrentUserRetweetId(status.getCurrentUserRetweetId());

    result.setInReplyToScreenName(status.getInReplyToScreenName());
    result.setInReplyToStatusId(status.getInReplyToStatusId());
    result.setInReplyToUserId(status.getInReplyToUserId());

    if (status.getGeoLocation() != null) {
        result.setLatitude(status.getGeoLocation().getLatitude());
        result.setLongitude(status.getGeoLocation().getLongitude());
    }

    result.setSource(status.getSource());
    result.setTrucated(status.isTruncated());
    result.setPossiblySensitive(status.isPossiblySensitive());

    result.setRetweet(status.getRetweetedStatus() != null);
    if (result.getRetweet()) {
        result.setRetweetStatusId(status.getRetweetedStatus().getId());
        result.setRetweetedText(status.getRetweetedStatus().getText());
    }
    result.setRetweeted(status.isRetweeted());
    result.setRetweetCount(status.getRetweetCount());
    result.setRetweetedByMe(status.isRetweetedByMe());

    result.setFavoriteCount(status.getFavoriteCount());
    result.setFavourited(status.isFavorited());

    if (status.getPlace() != null) {
        result.setPlace(status.getPlace().getFullName());
    }

    Scopes scopesObj = status.getScopes();
    if (scopesObj != null) {
        List scopes = Arrays.asList(scopesObj.getPlaceIds());
        result.setScopes(scopes);
    }
    return result;
}

From source file:com.raythos.sentilexo.twitter.utils.TwitterUtils.java

public static String relevantQueryTextFromStatus(String searchQueries, Status status) {
    String query;//from   w  w  w.  j  a v  a 2  s . c  o  m
    String statusText;
    if (status.getRetweetedStatus() != null)
        statusText = status.getRetweetedStatus().getText();
    else
        statusText = status.getText();
    query = queryTermsInStatus(searchQueries, statusText);
    return query;
}

From source file:com.raythos.sentilexo.twitter.utils.TwitterUtils.java

public static List<String> relevantQueryTermsFromStatus(String searchQuery, Status status) {
    List<String> result;
    String statusText;/*from ww  w.  j a  v a2  s.  c  om*/
    if (status.getRetweetedStatus() != null)
        statusText = status.getRetweetedStatus().getText();
    else
        statusText = status.getText();
    result = queryTermsListInStatus(searchQuery, statusText);
    return result;
}

From source file:com.revolucion.secretwit.ui.timeline.TweetCellRenderer.java

License:Open Source License

@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
        boolean cellHasFocus) {
    setComponentOrientation(list.getComponentOrientation());

    if (isSelected) {
        setBackground(list.getSelectionBackground());
        setForeground(list.getSelectionForeground());
    } else {//from   w  ww  . j  a  va 2  s  . co  m
        // Check for rollover
        Color backgroundColor = list.getBackground();
        ListUI ui = list.getUI();
        if (ui instanceof TimelineListUI) {
            int rolledOverIndex = ((TimelineListUI) ui).getRolledOverIndex();
            if (rolledOverIndex != -1 && rolledOverIndex == index) {
                backgroundColor = Colors.TIMELINE_ROLLOVER;
            }
        }

        setBackground(backgroundColor);
        setForeground(list.getForeground());
    }

    setEnabled(list.isEnabled());
    setFont(list.getFont());

    Status status = (Status) value;
    if (status != null) {
        BufferedImage image = loadImage(status);

        labelIcon.setIcon(new ImageIcon(image));
        labelDate.setText(new PrettyTime().format(status.getCreatedAt()) + " via " + parseSource(status));
        labelUsername.setText(status.getUser().getScreenName());
        labelRealname.setText(status.getUser().getName());

        String statusText = status.getText();
        areaMessage.setText(statusText);

        if (StegoUtils.doesProfileImageHaveWatermark(image)) {
            String decodedStatus = StegoUtils.decodeTweet(statusText);
            if (decodedStatus != null && !decodedStatus.isEmpty()) {
                labelSecret.setText(decodedStatus);
                labelSecret.setVisible(true);
            } else
                labelSecret.setVisible(false);
        } else
            labelSecret.setVisible(false);
    }

    return this;
}

From source file:com.rhymestore.twitter.stream.GetMentionsListener.java

License:Open Source License

@Override
public void onStatus(final Status status) {
    UserMentionEntity[] mentions = status.getUserMentionEntities();
    if (mentions != null) {
        for (UserMentionEntity mention : mentions) {
            try {
                // Check if there is any mention to us
                if (isCurrentUser(twitter, mention.getScreenName())) {
                    // Only reply if it is a valid mention
                    if (isValidMention(status) && !isCurrentUser(twitter, status.getUser().getScreenName())) {
                        LOGGER.debug("Processing tweet {} from {}", status.getId(),
                                status.getUser().getScreenName());

                        ReplyCommand reply = new ReplyCommand(twitter, wordParser, rhymeStore, status);
                        reply.execute();
                    } else {
                        LOGGER.debug("Ignoring mention: {}", status.getText());
                    }/*w  ww.j a  va 2  s.c  om*/

                    // Do not process the same tweet more than once
                    break;
                }
            } catch (TwitterException ex) {
                LOGGER.error("Could not process status: {}", status.getText());
            }
        }
    }
}

From source file:com.rhymestore.twitter.stream.GetMentionsListener.java

License:Open Source License

/**
 * Checks if the given mention is a valid mention according to the {@link WordParser} rules.
 * /*from w  w  w  . j  a va  2 s .  co m*/
 * @param mention The mention to check.
 * @return Boolean indicating if the given mention is a valid mention.
 */
private boolean isValidMention(final Status mention) {
    String lastWord = WordUtils.getLastWord(mention.getText());
    return wordParser.isWord(lastWord);
}

From source file:com.richardstansbury.tweetfollow.TwitterHelper.java

License:Open Source License

/**
 * Process's received Twitter status updates based upon the filter query.
 *
 * Implemented as part of the Status Listener Class.
 * @param status - a status update received by the listener.
 *//*from  www.  j av  a2s . c  o m*/
@Override
public void onStatus(Status status) {
    String tweetStr = status.getUser().getScreenName() + ": " + status.getText() + "(" + status.getCreatedAt()
            + ")";
    _tweets.add(0, tweetStr);
    _parent.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            _adapter.notifyDataSetChanged();
        }
    });
}

From source file:com.rowland.hashtrace.utility.Utility.java

License:Apache License

public static Tweet createTweet(Status status) {
    User user = status.getUser();/*  ww w  .  j a v a2 s. c  o  m*/

    long tweet_id = status.getId();

    String tweet_text = status.getText();

    Date tweet_text_date = status.getCreatedAt();

    int tweet_retweet_count = status.getRetweetCount();

    int tweet_favourite_count = status.getFavoriteCount();

    int tweet_mentions_count = status.getUserMentionEntities().length;

    String user_name = user.getScreenName();

    String user_image_url = user.getBiggerProfileImageURL();

    String user_cover_url = user.getProfileBackgroundImageURL();

    String user_location = user.getLocation();

    String user_description = user.getDescription();

    Tweet tweet = new Tweet(tweet_id, tweet_text, tweet_text_date, tweet_retweet_count, tweet_favourite_count,
            tweet_mentions_count, user_name, user_image_url, user_location, user_description, user_cover_url);

    return tweet;
}

From source file:com.sinfonier.drains.TweetIt.java

License:Apache License

@Override
public void userexecute() {

    ConfigurationBuilder config = new ConfigurationBuilder();
    config.setOAuthConsumerKey(this.CONSUMER_KEY);
    config.setOAuthConsumerSecret(this.CONSUMER_SECRET);
    config.setOAuthAccessToken(this.ACCESS_TOKEN);
    config.setOAuthAccessTokenSecret(this.ACCESS_TOKEN_SECRET);
    config.setJSONStoreEnabled(true);/*  w w  w . java  2s .  co  m*/
    config.setIncludeEntitiesEnabled(true);
    try {
        TwitterFactory tf = new TwitterFactory(config.build());
        Twitter twitter = tf.getInstance();
        Status status = twitter.updateStatus(this.customText + " " + this.getField(this.fieldToTweet));
        System.out.println("Successfully updated the status to [" + status.getText() + "].");
    } catch (TwitterException te) {
        te.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
}