diff options
Diffstat (limited to 'songdbj/javazoom/jl/player/AudioDeviceFactory.java')
-rw-r--r-- | songdbj/javazoom/jl/player/AudioDeviceFactory.java | 87 |
1 files changed, 0 insertions, 87 deletions
diff --git a/songdbj/javazoom/jl/player/AudioDeviceFactory.java b/songdbj/javazoom/jl/player/AudioDeviceFactory.java deleted file mode 100644 index 2d502d2aad..0000000000 --- a/songdbj/javazoom/jl/player/AudioDeviceFactory.java +++ /dev/null | |||
@@ -1,87 +0,0 @@ | |||
1 | /* | ||
2 | * 11/19/04 1.0 moved to LGPL. | ||
3 | * 29/01/00 Initial version. mdm@techie.com | ||
4 | *----------------------------------------------------------------------- | ||
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU Library General Public License as published | ||
7 | * by the Free Software Foundation; either version 2 of the License, or | ||
8 | * (at your option) any later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU Library General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU Library General Public | ||
16 | * License along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
18 | *---------------------------------------------------------------------- | ||
19 | */ | ||
20 | |||
21 | package javazoom.jl.player; | ||
22 | |||
23 | import javazoom.jl.decoder.JavaLayerException; | ||
24 | |||
25 | /** | ||
26 | * An <code>AudioDeviceFactory</code> class is responsible for creating | ||
27 | * a specific <code>AudioDevice</code> implementation. A factory implementation | ||
28 | * can be as simple or complex as desired and may support just one implementation | ||
29 | * or may return several implementations depending upon the execution | ||
30 | * environment. | ||
31 | * <p> | ||
32 | * When implementing a factory that provides an AudioDevice that uses | ||
33 | * class that may not be present, the factory should dynamically link to any | ||
34 | * specific implementation classes required to instantiate or test the audio | ||
35 | * implementation. This is so that the application as a whole | ||
36 | * can run without these classes being present. The audio | ||
37 | * device implementation, however, will usually statically link to the classes | ||
38 | * required. (See the JavaSound deivce and factory for an example | ||
39 | * of this.) | ||
40 | * | ||
41 | * @see FactoryRegistry | ||
42 | * | ||
43 | * @since 0.0.8 | ||
44 | * @author Mat McGowan | ||
45 | */ | ||
46 | public abstract class AudioDeviceFactory | ||
47 | { | ||
48 | /** | ||
49 | * Creates a new <code>AudioDevice</code>. | ||
50 | * | ||
51 | * @return a new instance of a specific class of <code>AudioDevice</code>. | ||
52 | * @throws JavaLayerException if an instance of AudioDevice could not | ||
53 | * be created. | ||
54 | */ | ||
55 | public abstract AudioDevice createAudioDevice() throws JavaLayerException; | ||
56 | |||
57 | /** | ||
58 | * Creates an instance of an AudioDevice implementation. | ||
59 | * @param loader The <code>ClassLoader</code> to use to | ||
60 | * load the named class, or null to use the | ||
61 | * system class loader. | ||
62 | * @param name The name of the class to load. | ||
63 | * @return A newly-created instance of the audio device class. | ||
64 | */ | ||
65 | protected AudioDevice instantiate(ClassLoader loader, String name) | ||
66 | throws ClassNotFoundException, | ||
67 | IllegalAccessException, | ||
68 | InstantiationException | ||
69 | { | ||
70 | AudioDevice dev = null; | ||
71 | |||
72 | Class cls = null; | ||
73 | if (loader==null) | ||
74 | { | ||
75 | cls = Class.forName(name); | ||
76 | } | ||
77 | else | ||
78 | { | ||
79 | cls = loader.loadClass(name); | ||
80 | } | ||
81 | |||
82 | Object o = cls.newInstance(); | ||
83 | dev = (AudioDevice)o; | ||
84 | |||
85 | return dev; | ||
86 | } | ||
87 | } | ||