From 9fee0ec4ca0c5b7a334cc29dbb58e76c7a4c736e Mon Sep 17 00:00:00 2001 From: Michiel Van Der Kolk Date: Mon, 11 Jul 2005 15:42:37 +0000 Subject: Songdb java version, source. only 1.5 compatible git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7101 a1c6a512-1295-4272-9138-f99709370657 --- songdbj/ArtistEntry.java | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 songdbj/ArtistEntry.java (limited to 'songdbj/ArtistEntry.java') diff --git a/songdbj/ArtistEntry.java b/songdbj/ArtistEntry.java new file mode 100644 index 0000000..fcaaac7 --- /dev/null +++ b/songdbj/ArtistEntry.java @@ -0,0 +1,56 @@ +import java.util.*; +import java.io.*; + +public class ArtistEntry extends Entry implements Comparable { + protected String name; + protected Vector albums; + protected int albumcount; + + public ArtistEntry(String n) { + name=n; + albums=new Vector(); + albumcount=0; + } + + public void addAlbum(AlbumEntry e) { + if(!albums.contains(e)) { + albums.add(e); + e.setArtist(this); + albumcount++; + Collections.sort(albums); + } + } + + public void removeAlbum(AlbumEntry e) { + albums.remove(e); + albumcount--; + } + + public int size() { return albumcount; } + + public int compareTo(Object o) { + return String.CASE_INSENSITIVE_ORDER.compare(name,((ArtistEntry)o).getName()); + } + + public String getName() { return name; } + public Collection getAlbums() { return albums; } + public void write(DataOutputStream w) throws IOException { + int x; + w.writeBytes(name); + for(x=TagDatabase.getInstance().artistlen-name.length();x>0;x--) + w.write(0); + Iterator i2 = albums.iterator(); + x=0; + while(i2.hasNext()) { + Entry e = (Entry) i2.next(); + w.writeInt(e.getOffset()); + x++; + } + for(;x