Exemple #1
0
 /**
  * Get all events in a specific location by country or city name.<br>
  * This method returns <em>all</em> events by subsequently calling {@link #getEvents(String,
  * String, int, String)} and concatenating the single results into one list.<br>
  * Pay attention if you use this method as it may produce a lot of network traffic and therefore
  * may consume a long time.
  *
  * @param location Specifies a location to retrieve events for
  * @param distance Find events within a specified radius (in kilometres)
  * @param apiKey A Last.fm API key.
  * @return a list containing all events
  */
 public static Collection<Event> getAllEvents(String location, String distance, String apiKey) {
   Collection<Event> events = null;
   int page = 1, total;
   do {
     PaginatedResult<Event> result = getEvents(location, distance, page, apiKey);
     total = result.getTotalPages();
     Collection<Event> pageResults = result.getPageResults();
     if (events == null) {
       // events is initialized here to initialize it with the right size and avoid array copying
       // later on
       events = new ArrayList<Event>(total * pageResults.size());
     }
     for (Event artist : pageResults) {
       events.add(artist);
     }
     page++;
   } while (page <= total);
   return events;
 }