}
MapUtilities.nullSafePut(params, "limit", limit);
Result result = Caller.getInstance().call(method, apiKey, params);
if (!result.isSuccessful())
return null;
DomElement element = result.getContentElement();
Collection<DomElement> children = element.getChildren(target);
Collection collection = new ArrayList(children.size());
boolean targetArtist = "artist".equals(target);
boolean targetTrack = "track".equals(target);
boolean targetAlbum = "album".equals(target);
for (DomElement domElement : children) {
if (targetArtist)
collection.add(ResponseBuilder.buildItem(domElement, Artist.class));
if (targetTrack)
collection.add(ResponseBuilder.buildItem(domElement, Track.class));
if (targetAlbum)
collection.add(ResponseBuilder.buildItem(domElement, Album.class));
}
long fromTime = 0;
long toTime = 0;
// workaround for geo.getMetroXXX methods, since they don't have from & to attributes if no dates were given upon calling
if (element.hasAttribute("from")) {
fromTime = 1000 * Long.parseLong(element.getAttribute("from"));
toTime = 1000 * Long.parseLong(element.getAttribute("to"));
}
return new Chart<T>(new Date(fromTime), new Date(toTime), collection);
}