/*package*/
 static ResponseList<UserList> createUserListList(HttpResponse res, Configuration conf)
     throws TwitterException {
   try {
     if (conf.isJSONStoreEnabled()) {
       TwitterObjectFactory.clearThreadLocalMap();
     }
     JSONArray list = res.asJSONArray();
     int size = list.length();
     ResponseList<UserList> users = new ResponseListImpl<UserList>(size, res);
     for (int i = 0; i < size; i++) {
       JSONObject userListJson = list.getJSONObject(i);
       UserList userList = new UserListJSONImpl(userListJson);
       users.add(userList);
       if (conf.isJSONStoreEnabled()) {
         TwitterObjectFactory.registerJSONObject(userList, userListJson);
       }
     }
     if (conf.isJSONStoreEnabled()) {
       TwitterObjectFactory.registerJSONObject(users, list);
     }
     return users;
   } catch (JSONException jsone) {
     throw new TwitterException(jsone);
   }
 }
 /*package*/ UserListJSONImpl(HttpResponse res, Configuration conf) throws TwitterException {
   super(res);
   if (conf.isJSONStoreEnabled()) {
     TwitterObjectFactory.clearThreadLocalMap();
   }
   JSONObject json = res.asJSONObject();
   init(json);
   if (conf.isJSONStoreEnabled()) {
     TwitterObjectFactory.registerJSONObject(this, json);
   }
 }
 DirectMessageJSONImpl(HttpResponse httpresponse, Configuration configuration)
 {
     super(httpresponse);
     httpresponse = httpresponse.asJSONObject();
     init(httpresponse);
     if (configuration.isJSONStoreEnabled())
     {
         TwitterObjectFactory.clearThreadLocalMap();
         TwitterObjectFactory.registerJSONObject(this, httpresponse);
     }
 }
 SavedSearchJSONImpl(HttpResponse httpresponse, Configuration configuration)
     throws TwitterException
 {
     super(httpresponse);
     if (configuration.isJSONStoreEnabled())
     {
         TwitterObjectFactory.clearThreadLocalMap();
     }
     httpresponse = httpresponse.asJSONObject();
     init(httpresponse);
     if (configuration.isJSONStoreEnabled())
     {
         TwitterObjectFactory.registerJSONObject(this, httpresponse);
     }
 }
  public void testGeoLocation() throws Exception {
    final double LATITUDE = 12.3456;
    final double LONGITUDE = -34.5678;

    Status withgeo =
        twitter1.updateStatus(
            new StatusUpdate(new java.util.Date().toString() + ": updating geo location")
                .location(new GeoLocation(LATITUDE, LONGITUDE)));
    assertNotNull(TwitterObjectFactory.getRawJSON(withgeo));
    assertEquals(
        withgeo, TwitterObjectFactory.createStatus(TwitterObjectFactory.getRawJSON(withgeo)));
    assertTrue(withgeo.getUser().isGeoEnabled());
    assertEquals(LATITUDE, withgeo.getGeoLocation().getLatitude());
    assertEquals(LONGITUDE, withgeo.getGeoLocation().getLongitude());
    assertFalse(twitter2.verifyCredentials().isGeoEnabled());
  }
    static ResponseList createDirectMessageList(HttpResponse httpresponse, Configuration configuration)
    {
        int i;
        JSONArray jsonarray;
        JSONObject jsonobject;
        DirectMessageJSONImpl directmessagejsonimpl;
        int j;
        try
        {
            if (configuration.isJSONStoreEnabled())
            {
                TwitterObjectFactory.clearThreadLocalMap();
            }
            jsonarray = httpresponse.asJSONArray();
            j = jsonarray.length();
            httpresponse = new ResponseListImpl(j, httpresponse);
        }
        // Misplaced declaration of an exception variable
        catch (HttpResponse httpresponse)
        {
            throw new TwitterException(httpresponse);
        }
        i = 0;
_L2:
        if (i >= j)
        {
            break MISSING_BLOCK_LABEL_89;
        }
        jsonobject = jsonarray.getJSONObject(i);
        directmessagejsonimpl = new DirectMessageJSONImpl(jsonobject);
        httpresponse.add(directmessagejsonimpl);
        if (configuration.isJSONStoreEnabled())
        {
            TwitterObjectFactory.registerJSONObject(directmessagejsonimpl, jsonobject);
        }
        break MISSING_BLOCK_LABEL_116;
        if (configuration.isJSONStoreEnabled())
        {
            TwitterObjectFactory.registerJSONObject(httpresponse, jsonarray);
        }
        return httpresponse;
        i++;
        if (true) goto _L2; else goto _L1
    static ResponseList createSavedSearchList(HttpResponse httpresponse, Configuration configuration)
        throws TwitterException
    {
        int i;
        if (configuration.isJSONStoreEnabled())
        {
            TwitterObjectFactory.clearThreadLocalMap();
        }
        JSONArray jsonarray = httpresponse.asJSONArray();
        ResponseListImpl responselistimpl;
        JSONObject jsonobject;
        SavedSearchJSONImpl savedsearchjsonimpl;
        try
        {
            responselistimpl = new ResponseListImpl(jsonarray.length(), httpresponse);
        }
        // Misplaced declaration of an exception variable
        catch (Configuration configuration)
        {
            throw new TwitterException((new StringBuilder()).append(configuration.getMessage()).append(":").append(httpresponse.asString()).toString(), configuration);
        }
        i = 0;
_L2:
        if (i < jsonarray.length())
        {
            jsonobject = jsonarray.getJSONObject(i);
            savedsearchjsonimpl = new SavedSearchJSONImpl(jsonobject);
            responselistimpl.add(savedsearchjsonimpl);
            if (configuration.isJSONStoreEnabled())
            {
                TwitterObjectFactory.registerJSONObject(savedsearchjsonimpl, jsonobject);
            }
            break MISSING_BLOCK_LABEL_146;
        }
        if (configuration.isJSONStoreEnabled())
        {
            TwitterObjectFactory.registerJSONObject(responselistimpl, jsonarray);
        }
        return responselistimpl;
        i++;
        if (true) goto _L2; else goto _L1
  public void testGeoMethods() throws Exception {
    GeoQuery query;
    ResponseList<Place> places;
    query = new GeoQuery(new GeoLocation(0, 0));

    places = twitter1.reverseGeoCode(query);
    assertEquals(0, places.size());

    query = new GeoQuery(new GeoLocation(37.78215, -122.40060));
    places = twitter1.reverseGeoCode(query);
    assertNotNull(TwitterObjectFactory.getRawJSON(places));
    assertEquals(
        places.get(0),
        TwitterObjectFactory.createPlace(TwitterObjectFactory.getRawJSON(places.get(0))));

    assertTrue(places.size() > 0);

    places = twitter1.searchPlaces(query);
    assertNotNull(TwitterObjectFactory.getRawJSON(places));
    assertEquals(
        places.get(0),
        TwitterObjectFactory.createPlace(TwitterObjectFactory.getRawJSON(places.get(0))));
    assertTrue(places.size() > 0);
    places = twitter1.getSimilarPlaces(new GeoLocation(37.78215, -122.40060), "SoMa", null, null);
    assertNotNull(TwitterObjectFactory.getRawJSON(places));
    assertEquals(
        places.get(0),
        TwitterObjectFactory.createPlace(TwitterObjectFactory.getRawJSON(places.get(0))));
    assertTrue(places.size() > 0);

    try {
      Place place = twitter1.getGeoDetails("5a110d312052166f");
      assertNotNull(TwitterObjectFactory.getRawJSON(place));
      assertEquals(place, TwitterObjectFactory.createPlace(TwitterObjectFactory.getRawJSON(place)));
      assertEquals("San Francisco, CA", place.getFullName());
      assertEquals("California, US", place.getContainedWithIn()[0].getFullName());
    } catch (TwitterException te) {
      // is being rate limited
      assertEquals(400, te.getStatusCode());
    }
    String sanFrancisco = "5a110d312052166f";
    Status status =
        twitter1.updateStatus(
            new StatusUpdate(new java.util.Date() + " status with place").placeId(sanFrancisco));
    assertNotNull(TwitterObjectFactory.getRawJSON(status));
    assertEquals(
        status, TwitterObjectFactory.createStatus(TwitterObjectFactory.getRawJSON(status)));
    assertEquals(sanFrancisco, status.getPlace().getId());
  }
  public List<Tweet> readFile(String fileLocation, int limit, String fromTweetId) {

    long startTime = System.currentTimeMillis();

    int errors = 0;
    int added = 0;
    int ignored = 0;
    int skipped = 0;

    List<Tweet> tweets = new ArrayList<Tweet>();

    try {

      // Read gzFile
      InputStream inputStream = new GZIPInputStream(new FileInputStream(fileLocation));
      Reader decoder = new InputStreamReader(inputStream);
      BufferedReader br = new BufferedReader(decoder);

      String status;

      while ((status = br.readLine()) != null) {

        // Ignore garbage and log output lines, all statuses start with JSON bracket
        if (!status.equals("") && status.charAt(0) == '{') {
          try {
            JSONObject jsonObject = new JSONObject(status);

            // We use created_at as an indicator that this is a Tweet.
            if (jsonObject.has("created_at")) {

              Status statusObject = TwitterObjectFactory.createStatus(status);

              Tweet tweet = this.getTweetObjectFromStatus(statusObject);

              if (fromTweetId != null) {

                if (fromTweetId.equals(tweet.getId())) {
                  this.log.write("StatusFileReader - Scanner pickup from " + fromTweetId);
                  fromTweetId = null;
                } else {
                  skipped++;
                }

                continue;
              }

              added++;
              tweets.add(tweet);

              if (limit > 0 && added >= limit) {
                break;
              }

            } else {
              ignored++;
            }

          } catch (JSONException e) {
            this.log.write(
                "Exception in StatusFileReader: Json Parse Failure on: "
                    + status
                    + ", "
                    + e.getMessage());
          }
        } else {
          ignored++;
        }
      }

      br.close();
      decoder.close();
      inputStream.close();

    } catch (Exception e) {
      this.log.write(
          "Exception in StatusFileReader: Error Reading File: "
              + e.getClass().getName()
              + ": "
              + e.getMessage());
    }

    long runTimeSeconds = TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis() - startTime);

    double ops = ((double) added / (double) Math.max(runTimeSeconds, 1));

    this.log.write(
        "StatusFileReader - "
            + fileLocation
            + " processed in "
            + runTimeSeconds
            + "s. "
            + added
            + " ok / "
            + errors
            + " errors / "
            + ignored
            + " ignored / "
            + skipped
            + " skipped. "
            + ops
            + " ops. Limit: "
            + limit
            + ", Fetch: "
            + tweets.size());

    return tweets;
  }