Source code: com/virtuosotechnologies/asaph/model/SongIDResultSet.java
1 /*
2 ================================================================================
3
4 FILE: SongIDResultSet.java
5
6 PROJECT:
7
8 Asaph
9
10 CONTENTS:
11
12 A result set of song IDs
13
14 PROGRAMMERS:
15
16 Daniel Azuma (DA) <dazuma@kagi.com>
17
18 COPYRIGHT:
19
20 Copyright (C) 2003 Daniel Azuma (dazuma@kagi.com)
21
22 This program is free software; you can redistribute it and/or
23 modify it under the terms of the GNU General Public License as
24 published by the Free Software Foundation; either version 2
25 of the License, or (at your option) any later version.
26
27 This program is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 GNU General Public License for more details.
31
32 You should have received a copy of the GNU General Public
33 License along with this program; if not, write to
34 Free Software Foundation, Inc.
35 59 Temple Place, Suite 330
36 Boston, MA 02111-1307 USA
37
38 ================================================================================
39 */
40
41
42 package com.virtuosotechnologies.asaph.model;
43
44
45 import java.util.Set;
46 import java.util.Collection;
47
48
49 /**
50 * A result set of SongIDs
51 */
52 public interface SongIDResultSet
53 extends Set
54 {
55 /**
56 * Create a copy of this result set that is linked to this one.
57 * A linked copy shares the song cache of the original. In addition, its initial
58 * data values are the same as the data for the original; however, the data can later
59 * be changed independent of the original.
60 *
61 * @return copy of this result set
62 */
63 public SongIDResultSet createLinkedCopy();
64
65
66 /**
67 * Get the SongDatabase that created this result set.
68 *
69 * @return SongDatabase
70 */
71 public SongDatabase getDatabase();
72
73
74 /**
75 * Get the data associated with the given SongID.
76 *
77 * @param songID SongID to query
78 * @return the entry for this songID, or null if there isn't one.
79 */
80 public Entry getEntryFor(
81 SongID songID);
82
83
84 /**
85 * Get an immutable collection view of the entries in the set.
86 * Each item in the collection is an Entry object.
87 *
88 * @return Collection of Entry objects
89 */
90 public Collection getEntryCollection();
91
92
93 /**
94 * Clear the song caches for all entries in the set
95 */
96 public void clearSongCache();
97
98
99 /**
100 * Interface representing an entry in the set.
101 */
102 public static interface Entry
103 {
104 /**
105 * Get the SongID for this entry
106 *
107 * @return the SongID
108 */
109 public SongID getSongID();
110
111
112 /**
113 * Get the data object for this entry
114 *
115 * @return the data object
116 */
117 public Object getData();
118
119
120 /**
121 * Set the data object for this entry
122 *
123 * @param data the data object
124 */
125 public void setData(
126 Object data);
127
128
129 /**
130 * Check out the Song referenced by this entry. Returns the Song, or
131 * null if the checkout fails for some reason.
132 * Also caches the value so that subsequent calls will return the cached
133 * value rather than checking out the song again. If the first checkout
134 * fails, a null value will be cached and returned from subsequent calls
135 * (i.e. an entry will try to check out a Song at most once).
136 *
137 * @return the Song
138 */
139 public Song getSong();
140 }
141 }