Example usage for twitter4j Status isPossiblySensitive

List of usage examples for twitter4j Status isPossiblySensitive

Introduction

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

Prototype

boolean isPossiblySensitive();

Source Link

Document

Returns true if the status contains a link that is identified as sensitive.

Usage

From source file:com.dwdesign.tweetings.model.ParcelableStatus.java

License:Open Source License

public ParcelableStatus(Status status, final long account_id, final boolean is_gap,
        final boolean large_inline_image_preview) {

    this.is_gap = is_gap;
    this.account_id = account_id;
    status_id = status.getId();//from w  w  w  .java 2 s  .co m
    is_retweet = status.isRetweet();
    final Status retweeted_status = is_retweet ? status.getRetweetedStatus() : null;
    final User retweet_user = retweeted_status != null ? status.getUser() : null;
    retweet_id = retweeted_status != null ? retweeted_status.getId() : -1;
    retweeted_by_id = retweet_user != null ? retweet_user.getId() : -1;
    retweeted_by_name = retweet_user != null ? retweet_user.getName() : null;
    retweeted_by_screen_name = retweet_user != null ? retweet_user.getScreenName() : null;
    if (retweeted_status != null) {
        status = retweeted_status;
    }
    final User user = status.getUser();
    user_id = user != null ? user.getId() : -1;
    name = user != null ? user.getName() : null;
    screen_name = user != null ? user.getScreenName() : null;
    profile_image_url = user != null ? user.getProfileImageURL() : null;
    profile_image_url_string = profile_image_url != null ? profile_image_url.toString() : null;
    is_protected = user != null ? user.isProtected() : false;
    is_verified = user != null ? user.isVerified() : false;
    final MediaEntity[] medias = status.getMediaEntities();

    status_timestamp = getTime(status.getCreatedAt());
    text_html = formatStatusText(status);
    final PreviewImage preview = getPreviewImage(text_html,
            large_inline_image_preview ? INLINE_IMAGE_PREVIEW_DISPLAY_OPTION_CODE_LARGE_HIGH
                    : INLINE_IMAGE_PREVIEW_DISPLAY_OPTION_CODE_SMALL);
    text_plain = status.getText();
    retweet_count = status.getRetweetCount();
    in_reply_to_screen_name = status.getInReplyToScreenName();
    in_reply_to_status_id = status.getInReplyToStatusId();
    source = status.getSource();
    location = new ParcelableLocation(status.getGeoLocation());
    location_string = location.toString();
    is_favorite = status.isFavorited();
    has_media = medias != null && medias.length > 0 || preview.has_image;
    text = text_html != null ? Html.fromHtml(text_html) : null;
    image_preview_url_string = preview.matched_url;
    image_orig_url_string = preview.orig_url;
    image_preview_url = parseURL(image_preview_url_string);
    text_unescaped = unescape(text_html);
    String play = null;
    URLEntity[] urls = status.getURLEntities();
    if (urls != null) {
        for (final URLEntity url : urls) {
            final URL tco_url = url.getURL();
            final URL expanded_url = url.getExpandedURL();
            if (tco_url != null && expanded_url != null
                    && expanded_url.toString().contains("play.google.com/store/apps")) {
                play = expanded_url.toString();
                break;
            }

        }
    }
    play_package = play;
    is_possibly_sensitive = status.isPossiblySensitive();
}

From source file:com.dwdesign.tweetings.util.Utils.java

License:Open Source License

public static ContentValues makeStatusContentValues(Status status, final long account_id) {
    if (status == null || status.getId() <= 0)
        return null;
    final ContentValues values = new ContentValues();
    values.put(Statuses.ACCOUNT_ID, account_id);
    values.put(Statuses.STATUS_ID, status.getId());
    final boolean is_retweet = status.isRetweet();
    final Status retweeted_status = is_retweet ? status.getRetweetedStatus() : null;
    if (retweeted_status != null) {
        final User retweet_user = status.getUser();
        values.put(Statuses.RETWEET_ID, retweeted_status.getId());
        values.put(Statuses.RETWEETED_BY_ID, retweet_user.getId());
        values.put(Statuses.RETWEETED_BY_NAME, retweet_user.getName());
        values.put(Statuses.RETWEETED_BY_SCREEN_NAME, retweet_user.getScreenName());
        status = retweeted_status;/*w w w .  j  a v a2 s  .  c o m*/
    }
    final User user = status.getUser();
    if (user != null) {
        final long user_id = user.getId();
        final String profile_image_url = user.getProfileImageURL().toString();
        final String name = user.getName(), screen_name = user.getScreenName();
        values.put(Statuses.USER_ID, user_id);
        values.put(Statuses.NAME, name);
        values.put(Statuses.SCREEN_NAME, screen_name);
        values.put(Statuses.IS_PROTECTED, user.isProtected() ? 1 : 0);
        values.put(Statuses.IS_VERIFIED, user.isVerified() ? 1 : 0);
        values.put(Statuses.PROFILE_IMAGE_URL, profile_image_url);
    }
    if (status.getCreatedAt() != null) {
        values.put(Statuses.STATUS_TIMESTAMP, status.getCreatedAt().getTime());
    }
    values.put(Statuses.TEXT, formatStatusText(status));
    values.put(Statuses.TEXT_PLAIN, status.getText());
    values.put(Statuses.RETWEET_COUNT, status.getRetweetCount());
    values.put(Statuses.IN_REPLY_TO_SCREEN_NAME, status.getInReplyToScreenName());
    values.put(Statuses.IN_REPLY_TO_STATUS_ID, status.getInReplyToStatusId());
    values.put(Statuses.SOURCE, status.getSource());
    values.put(Statuses.IS_POSSIBLY_SENSITIVE, status.isPossiblySensitive());
    final GeoLocation location = status.getGeoLocation();
    if (location != null) {
        values.put(Statuses.LOCATION, location.getLatitude() + "," + location.getLongitude());
    }
    values.put(Statuses.IS_RETWEET, is_retweet ? 1 : 0);
    values.put(Statuses.IS_FAVORITE, status.isFavorited() ? 1 : 0);
    return values;
}

From source file:com.github.jcustenborder.kafka.connect.twitter.StatusConverter.java

License:Apache License

public static void convert(Status status, Struct struct) {
    struct.put("CreatedAt", status.getCreatedAt()).put("Id", status.getId()).put("Text", status.getText())
            .put("Source", status.getSource()).put("Truncated", status.isTruncated())
            .put("InReplyToStatusId", status.getInReplyToStatusId())
            .put("InReplyToUserId", status.getInReplyToUserId())
            .put("InReplyToScreenName", status.getInReplyToScreenName()).put("Favorited", status.isFavorited())
            .put("Retweeted", status.isRetweeted()).put("FavoriteCount", status.getFavoriteCount())
            .put("Retweet", status.isRetweet()).put("RetweetCount", status.getRetweetCount())
            .put("RetweetedByMe", status.isRetweetedByMe())
            .put("CurrentUserRetweetId", status.getCurrentUserRetweetId())
            .put("PossiblySensitive", status.isPossiblySensitive()).put("Lang", status.getLang());

    Struct userStruct;//from  ww  w . ja  v  a2s .com
    if (null != status.getUser()) {
        userStruct = new Struct(USER_SCHEMA);
        convert(status.getUser(), userStruct);
    } else {
        userStruct = null;
    }
    struct.put("User", userStruct);

    Struct placeStruct;
    if (null != status.getPlace()) {
        placeStruct = new Struct(PLACE_SCHEMA);
        convert(status.getPlace(), placeStruct);
    } else {
        placeStruct = null;
    }
    struct.put("Place", placeStruct);

    Struct geoLocationStruct;
    if (null != status.getGeoLocation()) {
        geoLocationStruct = new Struct(GEO_LOCATION_SCHEMA);
        convert(status.getGeoLocation(), geoLocationStruct);
    } else {
        geoLocationStruct = null;
    }
    struct.put("GeoLocation", geoLocationStruct);
    List<Long> contributers = new ArrayList<>();

    if (null != status.getContributors()) {
        for (Long l : status.getContributors()) {
            contributers.add(l);
        }
    }
    struct.put("Contributors", contributers);

    List<String> withheldInCountries = new ArrayList<>();
    if (null != status.getWithheldInCountries()) {
        for (String s : status.getWithheldInCountries()) {
            withheldInCountries.add(s);
        }
    }
    struct.put("WithheldInCountries", withheldInCountries);

    struct.put("HashtagEntities", convert(status.getHashtagEntities()));
    struct.put("UserMentionEntities", convert(status.getUserMentionEntities()));
    struct.put("MediaEntities", convert(status.getMediaEntities()));
    struct.put("SymbolEntities", convert(status.getSymbolEntities()));
    struct.put("URLEntities", convert(status.getURLEntities()));
}

From source file:com.marpies.ane.twitter.utils.StatusUtils.java

License:Apache License

public static JSONObject getJSON(Status status) throws JSONException {
    JSONObject statusJSON = new JSONObject();
    statusJSON.put("id", status.getId());
    statusJSON.put("idStr", String.valueOf(status.getId()));
    statusJSON.put("text", status.getText());
    statusJSON.put("replyToUserID", status.getInReplyToUserId());
    statusJSON.put("replyToStatusID", status.getInReplyToStatusId());
    statusJSON.put("likesCount", status.getFavoriteCount());
    statusJSON.put("retweetCount", status.getRetweetCount());
    statusJSON.put("isRetweet", status.isRetweet());
    statusJSON.put("isSensitive", status.isPossiblySensitive());
    statusJSON.put("createdAt", status.getCreatedAt());
    Status retweetedStatus = status.getRetweetedStatus();
    if (retweetedStatus != null) {
        statusJSON.put("retweetedStatus", getJSON(retweetedStatus));
    }/* w w  w.  ja v a  2 s  .  co  m*/
    User user = status.getUser();
    if (user != null) {
        statusJSON.put("user", UserUtils.getJSON(user));
    }
    return statusJSON;
}

From source file:com.ofbizian.camelympics.MainApp.java

License:Open Source License

public static void main(String[] args) throws Exception {
    System.out.println("___________________Camelympics___________________");
    System.out.println("Open your web browser on http://localhost:8080");
    System.out.println("Press ctrl+c to stop this application");
    System.out.println("__________________________________________________");
    Main main = new Main();
    main.enableHangupSupport();//from   w w  w .  j ava 2  s  .c om
    main.addRouteBuilder(new RouteBuilder() {

        @Override
        public void configure() throws Exception {

            PropertiesComponent properties = new PropertiesComponent();
            properties.setLocation("classpath:app.properties");
            properties.setSystemPropertiesMode(PropertiesComponent.SYSTEM_PROPERTIES_MODE_OVERRIDE);
            getContext().addComponent("properties", properties);

            ThreadPoolProfile throttlerPool = new ThreadPoolProfile("throttlerPool");
            throttlerPool.setRejectedPolicy(ThreadPoolRejectedPolicy.Discard);
            throttlerPool.setMaxQueueSize(10);
            throttlerPool.setMaxPoolSize(2);
            throttlerPool.setPoolSize(2);
            getContext().getExecutorServiceManager().registerThreadPoolProfile(throttlerPool);
            getContext().getShutdownStrategy().setTimeout(1);

            from("twitter://streaming/filter?type=event&keywords={{searchTerm}}&accessToken={{accessToken}}&accessTokenSecret={{accessTokenSecret}}&consumerKey={{consumerKey}}&consumerSecret={{consumerSecret}}")

                    .to("log:tweetStream?level=INFO&groupInterval=10000&groupDelay=50000&groupActiveOnly=false")

                    .process(new Processor() {

                        @Override
                        public void process(Exchange exchange) throws Exception {
                            tweetCount++;
                            Status status = exchange.getIn().getBody(Status.class);
                            MediaEntity[] mediaEntities = status.getMediaEntities();
                            if (mediaEntities != null && !status.isPossiblySensitive()) { //nsfw
                                for (MediaEntity mediaEntity : mediaEntities) {
                                    imageCount++;
                                    exchange.getIn()
                                            .setBody(new Tweet().withName(status.getUser().getScreenName())
                                                    .withText(status.getText()).withCount(tweetCount)
                                                    .withImageCount(imageCount)
                                                    .withTweetUrl(mediaEntity.getDisplayURL().toString())
                                                    .withImageUrl(mediaEntity.getMediaURLHttps().toString()));

                                    exchange.getIn().setHeader("UNIQUE_IMAGE_URL",
                                            mediaEntity.getMediaURL().toString());
                                    break; //grab only the first image
                                }
                            }
                        }
                    })

                    .filter(body().isInstanceOf(Tweet.class))

                    .idempotentConsumer(header("UNIQUE_IMAGE_URL"),
                            MemoryIdempotentRepository.memoryIdempotentRepository(10000))

                    .throttle(1).timePeriodMillis(500).asyncDelayed().executorServiceRef("throttlerPool")

                    .marshal().json(JsonLibrary.Jackson).convertBodyTo(String.class)

                    .to("websocket://0.0.0.0:8080/camelympics?sendToAll=true&staticResources=classpath:web/.");
        }
    });

    main.run();
}

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 ww  w .j  a va  2s  .  co  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 va  2 s  .  c  o 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:de.vanita5.twittnuker.model.ParcelableStatus.java

License:Open Source License

public ParcelableStatus(final Status orig, final long account_id, final boolean is_gap) {
    this.is_gap = is_gap;
    this.account_id = account_id;
    id = orig.getId();//from  w  ww. j  a  v  a  2  s  .co m
    timestamp = getTime(orig.getCreatedAt());
    is_retweet = orig.isRetweet();
    final Status retweeted = orig.getRetweetedStatus();
    final User retweet_user = retweeted != null ? orig.getUser() : null;
    retweet_id = retweeted != null ? retweeted.getId() : -1;
    //NOTE getTime(orig.getCreatedAt())
    retweet_timestamp = retweeted != null ? getTime(retweeted.getCreatedAt()) : -1;
    retweeted_by_id = retweet_user != null ? retweet_user.getId() : -1;
    retweeted_by_name = retweet_user != null ? retweet_user.getName() : null;
    retweeted_by_screen_name = retweet_user != null ? retweet_user.getScreenName() : null;
    retweeted_by_profile_image = retweet_user != null
            ? ParseUtils.parseString(retweet_user.getProfileImageUrlHttps())
            : null;
    final Status status = retweeted != null ? retweeted : orig;
    final User user = status.getUser();
    user_id = user.getId();
    user_name = user.getName();
    user_screen_name = user.getScreenName();
    user_profile_image_url = ParseUtils.parseString(user.getProfileImageUrlHttps());
    user_is_protected = user.isProtected();
    user_is_verified = user.isVerified();
    user_is_following = user.isFollowing();
    text_html = formatStatusText(status);
    media = ParcelableMedia.fromEntities(status);
    text_plain = status.getText();
    retweet_count = status.getRetweetCount();
    favorite_count = status.getFavoriteCount();
    reply_count = status.getReplyCount();
    descendent_reply_count = status.getDescendentReplyCount();
    in_reply_to_name = getInReplyToName(status);
    in_reply_to_screen_name = status.getInReplyToScreenName();
    in_reply_to_status_id = status.getInReplyToStatusId();
    in_reply_to_user_id = status.getInReplyToUserId();
    source = status.getSource();
    location = new ParcelableLocation(status.getGeoLocation());
    is_favorite = status.isFavorited();
    text_unescaped = toPlainText(text_html);
    my_retweet_id = retweeted_by_id == account_id ? id : -1;
    is_possibly_sensitive = status.isPossiblySensitive();
    mentions = ParcelableUserMention.fromUserMentionEntities(status.getUserMentionEntities());
    first_media = media != null && media.length > 0 ? media[0].url : null;
}

From source file:de.vanita5.twittnuker.util.ContentValuesCreator.java

License:Open Source License

public static ContentValues makeStatusContentValues(final Status orig, final long accountId,
        final boolean largeProfileImage) {
    if (orig == null || orig.getId() <= 0)
        return null;
    final ContentValues values = new ContentValues();
    values.put(Statuses.ACCOUNT_ID, accountId);
    values.put(Statuses.STATUS_ID, orig.getId());
    values.put(Statuses.STATUS_TIMESTAMP, orig.getCreatedAt().getTime());
    values.put(Statuses.MY_RETWEET_ID, orig.getCurrentUserRetweet());
    final boolean isRetweet = orig.isRetweet();
    final Status status;
    final Status retweetedStatus = isRetweet ? orig.getRetweetedStatus() : null;
    if (retweetedStatus != null) {
        final User retweetUser = orig.getUser();
        values.put(Statuses.RETWEET_ID, retweetedStatus.getId());
        values.put(Statuses.RETWEET_TIMESTAMP, retweetedStatus.getCreatedAt().getTime());
        values.put(Statuses.RETWEETED_BY_USER_ID, retweetUser.getId());
        values.put(Statuses.RETWEETED_BY_USER_NAME, retweetUser.getName());
        values.put(Statuses.RETWEETED_BY_USER_SCREEN_NAME, retweetUser.getScreenName());
        values.put(Statuses.RETWEETED_BY_USER_PROFILE_IMAGE,
                ParseUtils.parseString(retweetUser.getProfileImageUrlHttps()));
        status = retweetedStatus;//from  ww w  .j a  v  a  2 s .  co  m
    } else {
        status = orig;
    }
    final User user = status.getUser();
    if (user != null) {
        final long userId = user.getId();
        final String profileImageUrl = ParseUtils.parseString(user.getProfileImageUrlHttps());
        final String name = user.getName(), screenName = user.getScreenName();
        values.put(Statuses.USER_ID, userId);
        values.put(Statuses.USER_NAME, name);
        values.put(Statuses.USER_SCREEN_NAME, screenName);
        values.put(Statuses.IS_PROTECTED, user.isProtected());
        values.put(Statuses.IS_VERIFIED, user.isVerified());
        values.put(Statuses.USER_PROFILE_IMAGE_URL,
                largeProfileImage ? getBiggerTwitterProfileImage(profileImageUrl) : profileImageUrl);
        values.put(CachedUsers.IS_FOLLOWING, user.isFollowing());
    }
    final String text_html = Utils.formatStatusText(status);
    values.put(Statuses.TEXT_HTML, text_html);
    values.put(Statuses.TEXT_PLAIN, status.getText());
    values.put(Statuses.TEXT_UNESCAPED, toPlainText(text_html));
    values.put(Statuses.RETWEET_COUNT, status.getRetweetCount());
    values.put(Statuses.REPLY_COUNT, status.getReplyCount());
    values.put(Statuses.DESCENDENT_REPLY_COUNT, status.getDescendentReplyCount());
    values.put(Statuses.IN_REPLY_TO_STATUS_ID, status.getInReplyToStatusId());
    values.put(Statuses.IN_REPLY_TO_USER_ID, status.getInReplyToUserId());
    values.put(Statuses.IN_REPLY_TO_USER_NAME, Utils.getInReplyToName(status));
    values.put(Statuses.IN_REPLY_TO_USER_SCREEN_NAME, status.getInReplyToScreenName());
    values.put(Statuses.SOURCE, status.getSource());
    values.put(Statuses.IS_POSSIBLY_SENSITIVE, status.isPossiblySensitive());
    final GeoLocation location = status.getGeoLocation();
    if (location != null) {
        values.put(Statuses.LOCATION, location.getLatitude() + "," + location.getLongitude());
    }
    values.put(Statuses.IS_RETWEET, isRetweet);
    values.put(Statuses.IS_FAVORITE, status.isFavorited());
    final ParcelableMedia[] media = ParcelableMedia.fromEntities(status);
    if (media != null) {
        values.put(Statuses.MEDIA, JSONSerializer.toJSONArrayString(media));
        values.put(Statuses.FIRST_MEDIA, media[0].url);
    }
    final ParcelableUserMention[] mentions = ParcelableUserMention.fromStatus(status);
    if (mentions != null) {
        values.put(Statuses.MENTIONS, JSONSerializer.toJSONArrayString(mentions));
    }
    return values;
}

From source file:nl.isaac.dotcms.twitter.pojo.CustomStatus.java

License:Creative Commons License

public CustomStatus(Status status) {
    this.createdAt = status.getCreatedAt();
    this.id = status.getId();
    this.id_str = String.valueOf(status.getId());
    this.text = status.getText();
    this.source = status.getSource();
    this.isTruncated = status.isTruncated();
    this.inReplyToStatusId = status.getInReplyToStatusId();
    this.inReplyToUserId = status.getInReplyToUserId();
    this.isFavorited = status.isFavorited();
    this.inReplyToScreenName = status.getInReplyToScreenName();
    this.geoLocation = status.getGeoLocation();
    this.place = status.getPlace();
    this.retweetCount = status.getRetweetCount();
    this.isPossiblySensitive = status.isPossiblySensitive();

    this.contributorsIDs = status.getContributors();

    this.retweetedStatus = status.getRetweetedStatus();
    this.userMentionEntities = status.getUserMentionEntities();
    this.urlEntities = status.getURLEntities();
    this.hashtagEntities = status.getHashtagEntities();
    this.mediaEntities = status.getMediaEntities();
    this.currentUserRetweetId = status.getCurrentUserRetweetId();

    this.isRetweet = status.isRetweet();
    this.isRetweetedByMe = status.isRetweetedByMe();

    this.rateLimitStatus = status.getRateLimitStatus();
    this.accessLevel = status.getAccessLevel();
    this.user = status.getUser();
}