diff options
Diffstat (limited to 'songdbj/org/tritonus/share/sampled/AudioFormatSet.java')
-rw-r--r-- | songdbj/org/tritonus/share/sampled/AudioFormatSet.java | 155 |
1 files changed, 0 insertions, 155 deletions
diff --git a/songdbj/org/tritonus/share/sampled/AudioFormatSet.java b/songdbj/org/tritonus/share/sampled/AudioFormatSet.java deleted file mode 100644 index 8d89541d77..0000000000 --- a/songdbj/org/tritonus/share/sampled/AudioFormatSet.java +++ /dev/null | |||
@@ -1,155 +0,0 @@ | |||
1 | /* | ||
2 | * AudioFormatSet.java | ||
3 | * | ||
4 | * This file is part of Tritonus: http://www.tritonus.org/ | ||
5 | */ | ||
6 | |||
7 | /* | ||
8 | * Copyright (c) 2000 by Florian Bomers <http://www.bomers.de> | ||
9 | * | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU Library General Public License as published | ||
13 | * by the Free Software Foundation; either version 2 of the License, or | ||
14 | * (at your option) any later version. | ||
15 | * | ||
16 | * This program is distributed in the hope that it will be useful, | ||
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
19 | * GNU Library General Public License for more details. | ||
20 | * | ||
21 | * You should have received a copy of the GNU Library General Public | ||
22 | * License along with this program; if not, write to the Free Software | ||
23 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
24 | * | ||
25 | */ | ||
26 | |||
27 | /* | ||
28 | |<--- this code is formatted to fit into 80 columns --->| | ||
29 | */ | ||
30 | |||
31 | package org.tritonus.share.sampled; | ||
32 | |||
33 | import java.util.ArrayList; | ||
34 | import java.util.Collection; | ||
35 | import java.util.Iterator; | ||
36 | |||
37 | import javax.sound.sampled.AudioFormat; | ||
38 | |||
39 | import org.tritonus.share.ArraySet; | ||
40 | import org.tritonus.share.sampled.AudioFormats; | ||
41 | |||
42 | |||
43 | /** | ||
44 | * A set where the elements are uniquely referenced by | ||
45 | * AudioFormats.equals rather than their object reference. | ||
46 | * No 2 equal AudioFormats can exist in the set. | ||
47 | * <p> | ||
48 | * This class provide convenience methods like | ||
49 | * <code>getAudioFormat(AudioFormat)</code> and | ||
50 | * <code>matches(AudioFormat)</code>. | ||
51 | * <p> | ||
52 | * The <code>contains(Object elem)</code> and <code>get(Object elem)</code> | ||
53 | * fail, if elem is not an instance of AudioFormat. | ||
54 | * <p> | ||
55 | * You shouldn't use the ArrayList specific functions | ||
56 | * like those that take index parameters. | ||
57 | * <p> | ||
58 | * It is not possible to add <code>null</code> elements. | ||
59 | * <p> | ||
60 | * Currently, the methods equals(.,.) and matches(.,.) of | ||
61 | * class AudioFormats are used. Let's hope that they will | ||
62 | * be integrated into AudioFormat. | ||
63 | */ | ||
64 | |||
65 | public class AudioFormatSet extends ArraySet<AudioFormat> | ||
66 | { | ||
67 | protected static final AudioFormat[] EMPTY_FORMAT_ARRAY = new AudioFormat[0]; | ||
68 | |||
69 | public AudioFormatSet() { | ||
70 | super(); | ||
71 | } | ||
72 | |||
73 | public AudioFormatSet(Collection<AudioFormat> c) { | ||
74 | super(c); | ||
75 | } | ||
76 | |||
77 | public boolean add(AudioFormat elem) { | ||
78 | if (elem==null || !(elem instanceof AudioFormat)) { | ||
79 | return false; | ||
80 | } | ||
81 | return super.add(elem); | ||
82 | } | ||
83 | |||
84 | public boolean contains(AudioFormat elem) { | ||
85 | if (elem==null || !(elem instanceof AudioFormat)) { | ||
86 | return false; | ||
87 | } | ||
88 | AudioFormat comp=(AudioFormat) elem; | ||
89 | Iterator it=iterator(); | ||
90 | while (it.hasNext()) { | ||
91 | if (AudioFormats.equals(comp, (AudioFormat) it.next())) { | ||
92 | return true; | ||
93 | } | ||
94 | } | ||
95 | return false; | ||
96 | } | ||
97 | |||
98 | public AudioFormat get(AudioFormat elem) { | ||
99 | if (elem==null || !(elem instanceof AudioFormat)) { | ||
100 | return null; | ||
101 | } | ||
102 | AudioFormat comp=(AudioFormat) elem; | ||
103 | Iterator it=iterator(); | ||
104 | while (it.hasNext()) { | ||
105 | AudioFormat thisElem=(AudioFormat) it.next(); | ||
106 | if (AudioFormats.equals(comp, thisElem)) { | ||
107 | return thisElem; | ||
108 | } | ||
109 | } | ||
110 | return null; | ||
111 | } | ||
112 | |||
113 | public AudioFormat getAudioFormat(AudioFormat elem) { | ||
114 | return (AudioFormat) get(elem); | ||
115 | } | ||
116 | |||
117 | /** | ||
118 | * Checks whether this Set contains an AudioFormat | ||
119 | * that matches <code>elem</code>. | ||
120 | * The first matching format is returned. If no element | ||
121 | * matches <code>elem</code>, <code>null</code> is returned. | ||
122 | * <p> | ||
123 | * @see AudioFormats#matches(AudioFormat, AudioFormat) | ||
124 | */ | ||
125 | public AudioFormat matches(AudioFormat elem) { | ||
126 | if (elem==null) { | ||
127 | return null; | ||
128 | } | ||
129 | Iterator it=iterator(); | ||
130 | while (it.hasNext()) { | ||
131 | AudioFormat thisElem=(AudioFormat) it.next(); | ||
132 | if (AudioFormats.matches(elem, thisElem)) { | ||
133 | return thisElem; | ||
134 | } | ||
135 | } | ||
136 | return null; | ||
137 | } | ||
138 | |||
139 | |||
140 | // $$mp: TODO: remove; should be obsolete | ||
141 | public AudioFormat[] toAudioFormatArray() { | ||
142 | return (AudioFormat[]) toArray(EMPTY_FORMAT_ARRAY); | ||
143 | } | ||
144 | |||
145 | |||
146 | public void add(int index, AudioFormat element) { | ||
147 | throw new UnsupportedOperationException("unsupported"); | ||
148 | } | ||
149 | |||
150 | public AudioFormat set(int index, AudioFormat element) { | ||
151 | throw new UnsupportedOperationException("unsupported"); | ||
152 | } | ||
153 | } | ||
154 | |||
155 | /*** AudioFormatSet.java ***/ | ||