From d8b95f787b73553e47a28bbf34eb0ead75647335 Mon Sep 17 00:00:00 2001 From: mdb Date: Fri, 13 Jul 2001 00:10:26 +0000 Subject: [PATCH] Added getSong() for looking up a song by id from the song array. git-svn-id: https://samskivert.googlecode.com/svn/trunk@175 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../robodj/src/java/robodj/repository/Entry.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/projects/robodj/src/java/robodj/repository/Entry.java b/projects/robodj/src/java/robodj/repository/Entry.java index 2250838d..dd1288d7 100644 --- a/projects/robodj/src/java/robodj/repository/Entry.java +++ b/projects/robodj/src/java/robodj/repository/Entry.java @@ -1,5 +1,5 @@ // -// $Id: Entry.java,v 1.2 2001/06/07 08:37:47 mdb Exp $ +// $Id: Entry.java,v 1.3 2001/07/13 00:10:26 mdb Exp $ package robodj.repository; @@ -33,6 +33,20 @@ public class Entry /** The songs associated with this entry. */ public transient Song[] songs; + /** + * Scans the songs array for the song with the specified id and + * returns it if found. Returns null otherwise. + */ + public Song getSong (int songid) + { + for (int i = 0; i < songs.length; i++) { + if (songs[i].songid == songid) { + return songs[i]; + } + } + return null; + } + public String toString () { return "[entryid=" + entryid + ", title=" + title +