如何在java eclipse中将last.fm api实现为搜索引擎?

如何在java eclipse中将last.fm api实现为搜索引擎?,java,last.fm,Java,Last.fm,我不知道如何正确地使用这个词,但我想使用这个代码和其他一些代码来搜索歌曲结果,然后在我选择它时显示它的信息。我也在eclipse中实现了last.fm api,但我不确定接下来该怎么做。任何建议都会有帮助。谢谢 static final ItemFactory<Track> FACTORY = new TrackFactory(); public static final String ARTIST_PAGE = "artistpage"; public static final

我不知道如何正确地使用这个词,但我想使用这个代码和其他一些代码来搜索歌曲结果,然后在我选择它时显示它的信息。我也在eclipse中实现了last.fm api,但我不确定接下来该怎么做。任何建议都会有帮助。谢谢

static final ItemFactory<Track> FACTORY = new TrackFactory();

public static final String ARTIST_PAGE = "artistpage";
public static final String ALBUM_PAGE = "albumpage";
public static final String TRACK_PAGE = "trackpage";

private String artist;
private String artistMbid;

protected String album;
private String albumMbid;
private int position = -1;

private boolean fullTrackAvailable;
private boolean nowPlaying;

private Date playedWhen;
protected int duration;     
protected String location;      

protected Map<String, String> lastFmExtensionInfos = new HashMap<String, String>();


protected Track(String name, String url, String artist) {
    super(name, url);
    this.artist = artist;
}

protected Track(String name, String url, String mbid, int playcount, int listeners, boolean streamable,
                String artist, String artistMbid, boolean fullTrackAvailable, boolean nowPlaying) {
    super(name, url, mbid, playcount, listeners, streamable);
    this.artist = artist;
    this.artistMbid = artistMbid;
    this.fullTrackAvailable = fullTrackAvailable;
    this.nowPlaying = nowPlaying;
}

public int getDuration() {
    return duration;
}

public String getArtist() {
    return artist;
}

public String getArtistMbid() {
    return artistMbid;
}

public String getAlbum() {
    return album;
}

public String getAlbumMbid() {
    return albumMbid;
}

public boolean isFullTrackAvailable() {
    return fullTrackAvailable;
}

public boolean isNowPlaying() {
    return nowPlaying;
}


public String getLocation() {
    return location;
}


public String getLastFmInfo(String key) {
    return lastFmExtensionInfos.get(key);

public Date getPlayedWhen() {
    return playedWhen;
}

public static Collection<Track> search(String track, String apiKey) {
    return search(null, track, 30, apiKey);
}


public static Collection<Track> search(String artist, String track, int limit, String apiKey) {
    Map<String, String> params = new HashMap<String, String>();
    params.put("track", track);
    params.put("limit", String.valueOf(limit));
    MapUtilities.nullSafePut(params, "artist", artist);
    Result result = Caller.getInstance().call("track.search", apiKey, params);
    if(!result.isSuccessful())
        return Collections.emptyList();
    DomElement element = result.getContentElement();
    DomElement matches = element.getChild("trackmatches");
    return ResponseBuilder.buildCollection(matches, Track.class);
}
静态最终项目工厂=新的TrackFactory();
公共静态最终字符串艺术家\u PAGE=“artistpage”;
公共静态最终字符串ALBUM\u PAGE=“albumpage”;
公共静态最终字符串轨迹\u PAGE=“trackpage”;
私人弦乐演奏家;
私人弦乐竞投;
保护字符串相册;
私有字符串albumbid;
私有整数位置=-1;
可提供专用布尔值;
私人游戏;
私人日期播放时间;
保护时间;
保护字符串位置;
受保护的映射LastFMExtensionInfo=新HashMap();
受保护的曲目(字符串名称、字符串url、字符串艺术家){
超级(名称、url);
这个艺术家=艺术家;
}
受保护的曲目(字符串名称、字符串url、字符串mbid、整数播放计数、整数侦听器、布尔流化、,
字符串艺术家、字符串艺术家投标、布尔fullTrackAvailable、布尔nowPlaying){
超级(名称、url、mbid、播放计数、侦听器、可流化);
这个艺术家=艺术家;
this.artistMbid=artistMbid;
this.fullTrackAvailable=fullTrackAvailable;
this.nowPlaying=nowPlaying;
}
public int getDuration(){
返回时间;
}
公共字符串getArtist(){
回归艺术家;
}
公共字符串getArtistMbid(){
退还投标书;
}
公共字符串getAlbum(){
返回相册;
}
公共字符串getAlbumMbid(){
返回ambumbid;
}
公共布尔值isFullTrackAvailable(){
返回可用的完整路径;
}
公共布尔值正在播放(){
现在就回来玩;
}
公共字符串getLocation(){
返回位置;
}
公共字符串getLastFmInfo(字符串键){
返回lastfmExtensionInfo.get(键);
公共日期getPlayedWhen(){
返回播放时间;
}
公共静态集合搜索(字符串轨迹、字符串键){
返回搜索(null、track、30、apiKey);
}
公共静态集合搜索(字符串艺术家、字符串轨迹、整数限制、字符串apiKey){
Map params=新的HashMap();
参数put(“轨道”,轨道);
参数put(“limit”,String.valueOf(limit));
MapUtilities.nullSafePut(参数“艺术家”,艺术家);
结果=Caller.getInstance().call(“track.search”、apiKey、params);
如果(!result.issusccessful())
返回集合。emptyList();
doElement元素=结果。getContentElement();
doElement matches=element.getChild(“trackmatches”);
返回ResponseBuilder.buildCollection(匹配项、跟踪项、类);
}