generated from Nekojimi/JavaMavenTemplate
Result: add source name, abbreviation, and score.
This commit is contained in:
parent
95f2db1926
commit
7e41eb1105
|
@ -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,12 +55,39 @@ public class Result
|
||||||
this.title = title;
|
this.title = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public String getSourceName()
|
||||||
public String toString() {
|
{
|
||||||
return "Result{" + "link=" + link + ", artist=" + artist + ", album=" + album + ", title=" + title + '}';
|
return sourceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAlbumArtist(String field)
|
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
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return "Result{" + "artist=" + artist + ", album=" + album + ", title=" + title + ", sourceAbbr=" + sourceAbbr + ", score=" + score + '}';
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAlbumArtist(String field)
|
||||||
{
|
{
|
||||||
// System.out.println("Parsing album-artist: " + field);
|
// System.out.println("Parsing album-artist: " + field);
|
||||||
String fieldLower = field.toLowerCase();
|
String fieldLower = field.toLowerCase();
|
||||||
|
@ -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…
Reference in New Issue