Example usage for twitter4j Location getCountryCode

List of usage examples for twitter4j Location getCountryCode

Introduction

In this page you can find the example usage for twitter4j Location getCountryCode.

Prototype

String getCountryCode();

Source Link

Usage

From source file:DataCollections.LocationHelper.java

public Location_dbo convertLocationToLocation_dbo(Location l) {

    Location_dbo loc = new Location_dbo();
    //LogPrinter.printLog("Conversion of current location to database object is started");
    loc.values[Location_dbo.map.get("country_code")].setValue(l.getCountryCode());
    loc.values[Location_dbo.map.get("country_name")].setValue(l.getCountryName());
    loc.values[Location_dbo.map.get("name")].setValue(l.getName());
    loc.values[Location_dbo.map.get("place_code")].setValue(String.valueOf(l.getPlaceCode()));
    loc.values[Location_dbo.map.get("place_name")].setValue(l.getPlaceName());
    loc.values[Location_dbo.map.get("url")].setValue(l.getURL());
    loc.values[Location_dbo.map.get("woeid")].setValue(String.valueOf(l.getWoeid()));
    //LogPrinter.printLog("Conversion of current location to database object complete");
    return loc;//  w w  w  .j a  va 2  s  . c  o  m
}

From source file:DataCollections.TrendsCollections.java

public void collectLatestTrendingHashTags() throws InterruptedException {

    ListIterator<Location> i = locations.listIterator();

    while (i.hasNext()) {
        Location l = i.next();

        try {/* w w w  .  ja  v  a2  s.  c o m*/
            trends = trendsresources.getPlaceTrends(l.getWoeid());
        } catch (TwitterException e) {
            Thread.sleep((e).getRetryAfter() * 1000 + 5000);
            i.previous();
            continue;

        }

        System.out.println("\nLocation:- CountryCode: " + l.getCountryCode() + " Country Name: "
                + l.getCountryName() + " Name: " + l.getName() + " PlaceCode: " + l.getPlaceCode()
                + " PlaceName: " + l.getPlaceName() + " URL: " + l.getURL() + " Woeid: " + l.getWoeid() + "\n");
        Trend[] ts = trends.getTrends();

        for (int t = 0; t < ts.length; t++) {
            System.out.println("Trend " + t + ts[t].getName() + " " + ts[t].toString());
        }
        htaghelper.insertTrends(ts);
    }
}