From 7e41eb11055105708c7e0fcfba05cdb0170bdd49 Mon Sep 17 00:00:00 2001 From: Jim Date: Fri, 1 Oct 2021 13:21:49 +0100 Subject: [PATCH] Result: add source name, abbreviation, and score. --- .../moe/nekojimi/musicsearcher/Result.java | 52 ++++++++++++++++--- 1 file changed, 46 insertions(+), 6 deletions(-) diff --git a/src/main/java/moe/nekojimi/musicsearcher/Result.java b/src/main/java/moe/nekojimi/musicsearcher/Result.java index a046226..2b7d66f 100644 --- a/src/main/java/moe/nekojimi/musicsearcher/Result.java +++ b/src/main/java/moe/nekojimi/musicsearcher/Result.java @@ -11,13 +11,18 @@ import java.net.URL; * * @author jim */ -public class Result +public class Result implements Comparable { private URL link; private String artist; private String album; private String title; + private String sourceName; + private String sourceAbbr; + + private double score; + public URL getLink() { return link; } @@ -50,12 +55,39 @@ public class Result 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 - public String toString() { - return "Result{" + "link=" + link + ", artist=" + artist + ", album=" + album + ", title=" + title + '}'; + public String toString() + { + return "Result{" + "artist=" + artist + ", album=" + album + ", title=" + title + ", sourceAbbr=" + sourceAbbr + ", score=" + score + '}'; } - public void setAlbumArtist(String field) + public void setAlbumArtist(String field) { // System.out.println("Parsing album-artist: " + field); String fieldLower = field.toLowerCase(); @@ -78,9 +110,17 @@ public class Result else album += word + " "; } + } + artist = artist.trim(); + album = album.trim(); } } - - + + @Override + public int compareTo(Result t) + { + return (int) Math.signum(score - t.score); + } + }