Example usage for twitter4j GeoLocation getLongitude

List of usage examples for twitter4j GeoLocation getLongitude

Introduction

In this page you can find the example usage for twitter4j GeoLocation getLongitude.

Prototype

public double getLongitude() 

Source Link

Document

returns the longitude of the geo location

Usage

From source file:twitterGateway_v2_06.java

License:Creative Commons License

public void SetupTwitter() {
    //twitterIn = new TwitterConnectStream();
    //accessToken = new AccessToken(TwitterAccessToken, TwitterAccessTokenSecret);
    //TwitterOAuthAuthorization.setOAuthAccessToken(accessToken);
    //TwitterOAuthAuthorization = new OAuthAuthorization(conf);
    //TwitterOAuthAuthorization.setOAuthConsumer(TwitterConsumerKey, TwitterConsumerSecret);
    ConfigurationBuilder cb = new ConfigurationBuilder();
    cb.setDebugEnabled(true).setOAuthConsumerKey(TwitterConsumerKey)
            .setOAuthConsumerSecret(TwitterConsumerSecret).setOAuthAccessToken(TwitterAccessToken)
            .setOAuthAccessTokenSecret(TwitterAccessTokenSecret);
    TwitterFactory tf = new TwitterFactory(cb.build());
    twitterOut = tf.getInstance();/* w w w . j ava  2 s . c o  m*/
    //  try {
    //  twitterOut.updateStatus("Hello World!");
    //  }
    //  catch (TwitterException ex) {
    //    println(ex);
    //  }
    ActivityLogAddLine("twitter connector ready");
    output = createWriter("log.txt");

    StatusListener twitterIn = new StatusListener() {
        public void onStatus(Status status) {
            double Longitude;
            double Latitude;
            GeoLocation GeoLoc = status.getGeoLocation();
            if (GeoLoc != null) {
                //println("YES got a location");
                Longitude = GeoLoc.getLongitude();
                Latitude = GeoLoc.getLatitude();
            } else {
                Longitude = 0;
                Latitude = 0;
            }
            println(TimeStamp() + "\t" + Latitude + "\t" + Longitude + "\t" + status.getUser().getScreenName()
                    + "\t" + status.getText());
            output.println(TimeStamp() + "\t" + Latitude + "\t" + Longitude + "\t"
                    + status.getUser().getScreenName() + "\t" + status.getText());
            output.flush();
            TwitterToOsc(status.getUser().getScreenName(), status.getText());
        }

        public void onDeletionNotice(StatusDeletionNotice statusDeletionNotice) {
            System.out.println("Got a status deletion notice id:" + statusDeletionNotice.getStatusId());
        }

        public void onTrackLimitationNotice(int numberOfLimitedStatuses) {
            System.out.println("Got track limitation notice:" + numberOfLimitedStatuses);
        }

        public void onScrubGeo(long userId, long upToStatusId) {
            System.out.println("Got scrub_geo event userId:" + userId + " upToStatusId:" + upToStatusId);
        }

        public void onException(Exception ex) {
            println("CAUGHT in the ACT: " + ex);
        }
    };

    ConfigurationBuilder cbIn = new ConfigurationBuilder();
    cbIn.setDebugEnabled(true).setOAuthConsumerKey(TwitterConsumerKey)
            .setOAuthConsumerSecret(TwitterConsumerSecret).setOAuthAccessToken(TwitterAccessToken)
            .setOAuthAccessTokenSecret(TwitterAccessTokenSecret);

    TwitterStreamFactory ts = new TwitterStreamFactory(cbIn.build());
    TwitterStream twitterStream = ts.getInstance();
    twitterStream.addListener(twitterIn);

    // filter() method internally creates a thread which manipulates TwitterStream and calls these adequate listener methods continuously.
    FilterQuery twitterFilter = new FilterQuery(0, TwitterFollowIDs, TwitterTrackWords);
    twitterStream.filter(twitterFilter);
}

From source file:Beans.Crawler.java

public String teste() {
    String result = "";
    int totalTweets = 0;
    long maxID = -1;

    GeoLocation geo = new GeoLocation(Double.parseDouble("-19.9225"), Double.parseDouble("-43.9450"));
    result += geo.getLatitude() + " " + geo.getLongitude() + "<br><br>";

    Twitter twitter = getTwitter();/*from ww  w . j a  va  2s.c  om*/

    try {
        Map<String, RateLimitStatus> rateLimitStatus = twitter.getRateLimitStatus("search");
        RateLimitStatus searchTweetsRateLimit = rateLimitStatus.get("/search/tweets");

        result += "You have " + searchTweetsRateLimit.getRemaining() + " calls remaining out of "
                + searchTweetsRateLimit.getLimit() + ", Limit resets in "
                + searchTweetsRateLimit.getSecondsUntilReset() + " seconds<br/><br/>";

        for (int queryNumber = 0; queryNumber < MAX_QUERIES; queryNumber++) {
            //   Do we need to delay because we've already hit our rate limits?
            if (searchTweetsRateLimit.getRemaining() == 0) {
                //   Yes we do, unfortunately ...
                //                        System.out.printf("!!! Sleeping for %d seconds due to rate limits\n", searchTweetsRateLimit.getSecondsUntilReset());

                //   If you sleep exactly the number of seconds, you can make your query a bit too early
                //   and still get an error for exceeding rate limitations
                //
                //    Adding two seconds seems to do the trick. Sadly, even just adding one second still triggers a
                //   rate limit exception more often than not.  I have no idea why, and I know from a Comp Sci
                //   standpoint this is really bad, but just add in 2 seconds and go about your business.  Or else.
                //               Thread.sleep((searchTweetsRateLimit.getSecondsUntilReset()+2) * 1000l);
            }

            Query q = new Query(SEARCH_TERM); //.geoCode((geo), 100, "mi");         // Search for tweets that contains this term
            q.setCount(TWEETS_PER_QUERY); // How many tweets, max, to retrieve
            //                    q.setGeoCode(geo, 100, Query.Unit.mi);
            //                    q.setSince("2012-02-20");
            //                                
            //            q.resultType("recent");                  // Get all tweets
            //            q.setLang("en");                     // English language tweets, please

            //   If maxID is -1, then this is our first call and we do not want to tell Twitter what the maximum
            //   tweet id is we want to retrieve.  But if it is not -1, then it represents the lowest tweet ID
            //   we've seen, so we want to start at it-1 (if we start at maxID, we would see the lowest tweet
            //   a second time...
            if (maxID != -1) {
                q.setMaxId(maxID - 1);
            }

            //   This actually does the search on Twitter and makes the call across the network
            QueryResult r = twitter.search(q);

            //   If there are NO tweets in the result set, it is Twitter's way of telling us that there are no
            //   more tweets to be retrieved.  Remember that Twitter's search index only contains about a week's
            //   worth of tweets, and uncommon search terms can run out of week before they run out of tweets
            if (r.getTweets().size() == 0) {
                break; // Nothing? We must be done
            }

            //   loop through all the tweets and process them.  In this sample program, we just print them
            //   out, but in a real application you might save them to a database, a CSV file, do some
            //   analysis on them, whatever...
            for (Status s : r.getTweets()) // Loop through all the tweets...
            {
                //   Increment our count of tweets retrieved
                totalTweets++;

                //   Keep track of the lowest tweet ID.  If you do not do this, you cannot retrieve multiple
                //   blocks of tweets...
                if (maxID == -1 || s.getId() < maxID) {
                    maxID = s.getId();
                }
                //   Do something with the tweet....
                result += "ID: " + s.getId() + " Data " + s.getCreatedAt().toString() + " user "
                        + s.getUser().getScreenName() + " texto: " + cleanText(s.getText()) + "  <br/>";

            }

            //   As part of what gets returned from Twitter when we make the search API call, we get an updated
            //   status on rate limits.  We save this now so at the top of the loop we can decide whether we need
            //   to sleep or not before making the next call.
            searchTweetsRateLimit = r.getRateLimitStatus();
        }

    } catch (Exception e) {
        //   Catch all -- you're going to read the stack trace and figure out what needs to be done to fix it
    }
    result += "<br><br>" + totalTweets + "<br>";
    return result;
}

From source file:bolt.DucksBoardMap.java

License:Apache License

@Override
public void execute(Tuple tuple) {
    GeoLocation tmp = (GeoLocation) tuple.getValueByField(this.fields[0]);

    if (tmp != null) {

        String val = "{\"value\": {\"latitude\": " + tmp.getLatitude() + ",\"longitude\": " + tmp.getLongitude()
                + " }}";
        dao.push(idString, val);
    }/*from  ww  w  .  j  a  v a2  s  .  c o m*/

}

From source file:br.com.porcelli.hornetq.integration.twitter.support.TweetMessageConverterSupport.java

License:Apache License

public static ServerMessage buildMessage(final String queueName, final Status status) {
    final ServerMessage msg = new ServerMessageImpl(status.getId(),
            InternalTwitterConstants.INITIAL_MESSAGE_BUFFER_SIZE);
    msg.setAddress(new SimpleString(queueName));
    msg.setDurable(true);/*w  w w  .j a  v a2 s  . co m*/

    msg.putStringProperty(TwitterConstants.KEY_MSG_TYPE, MessageType.TWEET.toString());
    msg.putStringProperty(TwitterConstants.KEY_CREATED_AT, read(status.getCreatedAt()));
    msg.putStringProperty(TwitterConstants.KEY_ID, read(status.getId()));

    msg.putStringProperty(TwitterConstants.KEY_TEXT, read(status.getText()));
    msg.putStringProperty(TwitterConstants.KEY_SOURCE, read(status.getSource()));
    msg.putStringProperty(TwitterConstants.KEY_TRUNCATED, read(status.isTruncated()));
    msg.putStringProperty(TwitterConstants.KEY_IN_REPLY_TO_STATUS_ID, read(status.getInReplyToStatusId()));
    msg.putStringProperty(TwitterConstants.KEY_IN_REPLY_TO_USER_ID, read(status.getInReplyToUserId()));
    msg.putStringProperty(TwitterConstants.KEY_IN_REPLY_TO_SCREEN_NAME, read(status.getInReplyToScreenName()));

    msg.putStringProperty(TwitterConstants.KEY_RETWEET, read(status.isRetweet()));
    msg.putStringProperty(TwitterConstants.KEY_FAVORITED, read(status.isFavorited()));

    msg.putStringProperty(TwitterConstants.KEY_ENTITIES_URLS_JSON, read(status.getURLEntities()));
    msg.putStringProperty(TwitterConstants.KEY_ENTITIES_HASHTAGS_JSON, read(status.getHashtagEntities()));
    msg.putStringProperty(TwitterConstants.KEY_ENTITIES_MENTIONS_JSON, read(status.getUserMentionEntities()));

    msg.putStringProperty(TwitterConstants.KEY_CONTRIBUTORS_JSON, read(status.getContributors()));

    if (status.getUser() != null) {
        buildUserData("", status.getUser(), msg);
    }

    GeoLocation gl;
    if ((gl = status.getGeoLocation()) != null) {
        msg.putStringProperty(TwitterConstants.KEY_GEO_LATITUDE, read(gl.getLatitude()));
        msg.putStringProperty(TwitterConstants.KEY_GEO_LONGITUDE, read(gl.getLongitude()));
    }

    Place place;
    if ((place = status.getPlace()) != null) {
        msg.putStringProperty(TwitterConstants.KEY_PLACE_ID, read(place.getId()));
        msg.putStringProperty(TwitterConstants.KEY_PLACE_URL, read(place.getURL()));
        msg.putStringProperty(TwitterConstants.KEY_PLACE_NAME, read(place.getName()));
        msg.putStringProperty(TwitterConstants.KEY_PLACE_FULL_NAME, read(place.getFullName()));
        msg.putStringProperty(TwitterConstants.KEY_PLACE_COUNTRY_CODE, read(place.getCountryCode()));
        msg.putStringProperty(TwitterConstants.KEY_PLACE_COUNTRY, read(place.getCountry()));
        msg.putStringProperty(TwitterConstants.KEY_PLACE_STREET_ADDRESS, read(place.getStreetAddress()));
        msg.putStringProperty(TwitterConstants.KEY_PLACE_TYPE, read(place.getPlaceType()));
        msg.putStringProperty(TwitterConstants.KEY_PLACE_GEO_TYPE, read(place.getGeometryType()));
        msg.putStringProperty(TwitterConstants.KEY_PLACE_BOUNDING_BOX_TYPE, read(place.getBoundingBoxType()));
        msg.putStringProperty(TwitterConstants.KEY_PLACE_BOUNDING_BOX_COORDINATES_JSON,
                read(place.getBoundingBoxCoordinates().toString()));
        msg.putStringProperty(TwitterConstants.KEY_PLACE_BOUNDING_BOX_GEOMETRY_COORDINATES_JSON,
                read(place.getGeometryCoordinates().toString()));
    }

    msg.putStringProperty(TwitterConstants.KEY_RAW_JSON, status.toString());

    return msg;
}

From source file:br.com.porcelli.hornetq.integration.twitter.support.TweetMessageConverterSupport.java

License:Apache License

public static ServerMessage buildMessage(final String queueName, final Tweet tweet) {
    final ServerMessage msg = new ServerMessageImpl(tweet.getId(),
            InternalTwitterConstants.INITIAL_MESSAGE_BUFFER_SIZE);
    msg.setAddress(new SimpleString(queueName));
    msg.setDurable(true);//from   w  ww.  j  a  va 2  s  . c  om

    msg.putStringProperty(TwitterConstants.KEY_MSG_TYPE, MessageType.TWEET.toString());

    msg.putStringProperty(TwitterConstants.KEY_ID, read(tweet.getId()));
    msg.putStringProperty(TwitterConstants.KEY_TEXT, read(tweet.getText()));
    msg.putStringProperty(TwitterConstants.KEY_SOURCE, read(tweet.getSource()));

    msg.putStringProperty(TwitterConstants.KEY_FROM_USER_ID, read(tweet.getFromUserId()));
    msg.putStringProperty(TwitterConstants.KEY_FROM_USER_NAME, read(tweet.getFromUser()));
    msg.putStringProperty(TwitterConstants.KEY_FROM_USER_PROFILE_IMAGE_URL, read(tweet.getProfileImageUrl()));

    msg.putStringProperty(TwitterConstants.KEY_TO_USER_ID, read(tweet.getToUserId()));
    msg.putStringProperty(TwitterConstants.KEY_TO_USER_SCREEN_NAME, read(tweet.getToUser()));
    msg.putStringProperty(TwitterConstants.KEY_LOCATION, read(tweet.getLocation()));
    msg.putStringProperty(TwitterConstants.KEY_ISO_LANG_CODE, read(tweet.getIsoLanguageCode()));

    msg.putStringProperty(TwitterConstants.KEY_CREATED_AT, read(tweet.getCreatedAt()));

    GeoLocation gl;
    if ((gl = tweet.getGeoLocation()) != null) {
        msg.putStringProperty(TwitterConstants.KEY_GEO_LATITUDE, read(gl.getLatitude()));
        msg.putStringProperty(TwitterConstants.KEY_GEO_LONGITUDE, read(gl.getLongitude()));
    }

    msg.putStringProperty(TwitterConstants.KEY_RAW_JSON, tweet.toString());

    return msg;
}

From source file:com.appspot.bitlyminous.handler.twitter.NearByHandler.java

License:Apache License

@Override
public StatusUpdate execute(Status tweet) {
    GeoLocation geoLocation = tweet.getGeoLocation();
    String text = getMentionText(tweet);
    if (geoLocation == null) {
        StatusUpdate reply = new StatusUpdate(
                ApplicationResources.getLocalizedString("com.appspot.bitlyminous.message.noLocation",
                        new String[] { "@" + tweet.getUser().getScreenName() }));
        reply.setInReplyToStatusId(tweet.getId());
        return reply;
    } else {/*from w  w w  .  j av a  2  s  .co  m*/
        try {
            GeoQuery query = new GeoQuery(geoLocation);
            List<Tip> nearbyTips = getFoursquareGateway()
                    .getNearbyTips(new com.appspot.bitlyminous.entity.GeoLocation(geoLocation.getLatitude(),
                            geoLocation.getLongitude()), 1);
            String status = buildTipsStatus(nearbyTips);

            if (nearbyTips.isEmpty()) {
                List<Venue> nearbyVenues = new ArrayList<Venue>();
                if (text != null) {
                    nearbyVenues = getFoursquareGateway().getNearbyVenues(
                            new com.appspot.bitlyminous.entity.GeoLocation(geoLocation.getLatitude(),
                                    geoLocation.getLongitude()),
                            text, 1);
                }
                status = status + buildVenuesStatus(nearbyVenues);
                if (nearbyVenues.isEmpty()) {
                    List<Place> nearbyPlaces = getTwitterClient().getNearbyPlaces(query);
                    status = status + buildPlacesStatus(nearbyPlaces);
                }

            }
            status = "@" + tweet.getUser().getScreenName() + " " + status;
            StatusUpdate reply = new StatusUpdate(status);
            reply.setInReplyToStatusId(tweet.getId());
            return reply;
        } catch (Exception e) {
            logger.log(Level.SEVERE, "Error while getting nearby places", e);
        }
        return null;
    }
}

From source file:com.daiv.android.twitter.ui.tweet_viewer.fragments.TweetFragment.java

License:Apache License

public void getInfo(final View favButton, final TextView favCount, final TextView retweetCount,
        final long tweetId, final View retweetButton) {

    Thread getInfo = new Thread(new Runnable() {
        @Override/*from   w w  w.j  ava  2  s . co m*/
        public void run() {
            String location = "";
            String via = "";
            long realTime = 0;
            boolean retweetedByMe = false;
            try {
                Twitter twitter = getTwitter();

                TwitterMultipleImageHelper helper = new TwitterMultipleImageHelper();
                status = twitter.showStatus(tweetId);

                ArrayList<String> i = new ArrayList<String>();

                if (picture) {
                    i = helper.getImageURLs(status, twitter);
                }

                final ArrayList<String> images = i;

                GeoLocation loc = status.getGeoLocation();
                try {
                    Geocoder geocoder = new Geocoder(context, Locale.getDefault());
                    List<Address> addresses = geocoder.getFromLocation(loc.getLatitude(), loc.getLongitude(),
                            1);
                    if (addresses.size() > 0) {
                        Address address = addresses.get(0);
                        location += address.getLocality() + ", " + address.getCountryName();
                    } else {
                        location = "";
                    }
                } catch (Exception x) {
                    location = "";
                }

                via = android.text.Html.fromHtml(status.getSource()).toString();

                final String sfavCount;
                if (status.isRetweet()) {
                    twitter4j.Status status2 = status.getRetweetedStatus();
                    via = android.text.Html.fromHtml(status2.getSource()).toString();
                    realTime = status2.getCreatedAt().getTime();
                    sfavCount = status2.getFavoriteCount() + "";
                } else {
                    realTime = status.getCreatedAt().getTime();
                    sfavCount = status.getFavoriteCount() + "";
                }

                retweetedByMe = status.isRetweetedByMe();
                final String retCount = "" + status.getRetweetCount();

                final String timeDisplay;

                if (!settings.militaryTime) {
                    timeDisplay = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.US).format(realTime)
                            + " " + DateFormat.getTimeInstance(DateFormat.SHORT, Locale.US).format(realTime);
                } else {
                    timeDisplay = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.GERMAN).format(realTime)
                            + " "
                            + DateFormat.getTimeInstance(DateFormat.SHORT, Locale.GERMAN).format(realTime);
                }
                final String fVia = " " + getResources().getString(R.string.via) + " " + via;
                final String fLoc = location.equals("") ? "" : "\n" + location;

                final boolean fRet = retweetedByMe;
                final long fTime = realTime;
                final Status fStatus = status;
                ((Activity) context).runOnUiThread(new Runnable() {
                    @Override
                    public void run() {

                        // you can't retweet a protected account
                        if (status.getUser().isProtected()) {
                            retweetButton.setOnClickListener(new View.OnClickListener() {
                                @Override
                                public void onClick(View v) {
                                    Toast.makeText(context, getString(R.string.protected_account),
                                            Toast.LENGTH_SHORT).show();
                                }
                            });
                        }

                        retweetCount.setText(" " + retCount);

                        if (retweetButton instanceof ImageButton) {
                            if (fRet) {
                                if (!settings.addonTheme) {
                                    ((ImageButton) retweetButton)
                                            .setColorFilter(context.getResources().getColor(R.color.app_color));
                                } else {
                                    ((ImageButton) retweetButton).setColorFilter(settings.accentInt);
                                }
                            } else {
                                ((ImageButton) retweetButton).clearColorFilter();
                            }
                        } else {
                            if (fRet) {
                                if (!settings.addonTheme) {
                                    retweetButton.setBackgroundColor(
                                            context.getResources().getColor(R.color.app_color));
                                } else {
                                    retweetButton.setBackgroundColor(settings.accentInt);
                                }
                            } else {
                                retweetButton.setBackgroundColor(
                                        getResources().getColor(android.R.color.transparent));
                            }
                        }

                        timetv.setText(timeDisplay + fVia);
                        timetv.append(fLoc);

                        favCount.setText(" " + sfavCount);

                        if (favButton instanceof ImageButton) {
                            if (fStatus.isFavorited()) {
                                TypedArray a = context.getTheme()
                                        .obtainStyledAttributes(new int[] { R.attr.favoritedButton });
                                int resource = a.getResourceId(0, 0);
                                a.recycle();

                                if (!settings.addonTheme) {
                                    ((ImageButton) favButton)
                                            .setColorFilter(context.getResources().getColor(R.color.app_color));
                                } else {
                                    ((ImageButton) favButton).setColorFilter(settings.accentInt);
                                }

                                ((ImageButton) favButton)
                                        .setImageDrawable(context.getResources().getDrawable(resource));
                                isFavorited = true;
                            } else {
                                TypedArray a = context.getTheme()
                                        .obtainStyledAttributes(new int[] { R.attr.notFavoritedButton });
                                int resource = a.getResourceId(0, 0);
                                a.recycle();

                                ((ImageButton) favButton)
                                        .setImageDrawable(context.getResources().getDrawable(resource));
                                isFavorited = false;

                                ((ImageButton) favButton).clearColorFilter();
                            }
                        } else {
                            if (fStatus.isFavorited()) {
                                TypedArray a = context.getTheme()
                                        .obtainStyledAttributes(new int[] { R.attr.favoritedButton });
                                int resource = a.getResourceId(0, 0);
                                a.recycle();

                                if (!settings.addonTheme) {
                                    favButton.setBackgroundColor(
                                            context.getResources().getColor(R.color.app_color));
                                } else {
                                    favButton.setBackgroundColor(settings.accentInt);
                                }

                                isFavorited = true;
                            } else {
                                isFavorited = false;

                                favButton.setBackgroundColor(
                                        getResources().getColor(android.R.color.transparent));
                            }
                        }

                        for (String s : images) {
                            Log.v("Test_image", s);
                        }
                    }
                });
            } catch (Exception e) {

            }
        }
    });

    getInfo.setPriority(Thread.MAX_PRIORITY);
    getInfo.start();
}

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

License:Open Source License

public ParcelableLocation(final GeoLocation location) {
    latitude = location != null ? location.getLatitude() : -1;
    longitude = location != null ? location.getLongitude() : -1;
}

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;//from   w ww.  jav  a  2  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(GeoLocation geoLocation, Struct struct) {
    if (null == geoLocation) {
        return;/*from   w  w  w .ja  v  a2  s.c  o m*/
    }
    struct.put("Latitude", geoLocation.getLatitude()).put("Longitude", geoLocation.getLongitude());
}