Result: add source name, abbreviation, and score.

master
Jim 3 years ago
parent 95f2db1926
commit 7e41eb1105
  1. 46
      src/main/java/moe/nekojimi/musicsearcher/Result.java

@ -11,13 +11,18 @@ import java.net.URL;
* *
* @author jim * @author jim
*/ */
public class Result public class Result implements Comparable<Result>
{ {
private URL link; private URL link;
private String artist; private String artist;
private String album; private String album;
private String title; private String title;
private String sourceName;
private String sourceAbbr;
private double score;
public URL getLink() { public URL getLink() {
return link; return link;
} }
@ -50,9 +55,36 @@ public class Result
this.title = title; this.title = title;
} }
public String getSourceName()
{
return sourceName;
}
public void setSource(String name, String abbr)
{
sourceName = name;
sourceAbbr = abbr;
}
public String getSourceAbbr()
{
return sourceAbbr;
}
public double getScore()
{
return score;
}
public void setScore(double score)
{
this.score = score;
}
@Override @Override
public String toString() { public String toString()
return "Result{" + "link=" + link + ", artist=" + artist + ", album=" + album + ", title=" + title + '}'; {
return "Result{" + "artist=" + artist + ", album=" + album + ", title=" + title + ", sourceAbbr=" + sourceAbbr + ", score=" + score + '}';
} }
public void setAlbumArtist(String field) public void setAlbumArtist(String field)
@ -78,9 +110,17 @@ public class Result
else else
album += word + " "; album += word + " ";
} }
} }
artist = artist.trim();
album = album.trim();
} }
} }
@Override
public int compareTo(Result t)
{
return (int) Math.signum(score - t.score);
}
} }

Loading…
Cancel
Save