upstream version 1.2.2
[debian/freetts] / com / sun / speech / engine / BaseAudioManager.java
1 /**
2  * Copyright 1998-2001 Sun Microsystems, Inc.
3  * 
4  * See the file "license.terms" for information on usage and
5  * redistribution of this file, and for a DISCLAIMER OF ALL 
6  * WARRANTIES.
7  */
8 package com.sun.speech.engine;
9
10 import java.util.Collection;
11
12 import javax.speech.AudioListener;
13 import javax.speech.AudioManager;
14
15 /**
16  * Supports the JSAPI 1.0 <code>AudioManager</code>
17  * interface.  Actual JSAPI implementations might want to extend
18  * or modify this implementation.
19  */
20 public class BaseAudioManager implements AudioManager {
21     /**
22      * List of <code>AudioListeners</code> registered for
23      * <code>AudioEvents</code> on this object.
24      */
25     protected Collection listeners;
26     
27     /** 
28      * Class constructor.
29      */
30     public BaseAudioManager() {
31         listeners = new java.util.ArrayList();
32     }
33
34     /**
35      * Requests notification of <code>AudioEvents</code> from the
36      * <code>AudioManager</code>.
37      *
38      * @param listener the listener to add
39      */
40     public void addAudioListener(AudioListener listener) {
41         if (!listeners.contains(listener)) {
42             listeners.add(listener);
43         }
44     }
45     
46     /**
47      * Removes an <code>AudioListener</code> from the list of
48      * <code>AudioListeners</code>.
49      *
50      * @param listener the listener to remove
51      */
52     public void removeAudioListener(AudioListener listener) {
53         listeners.remove(listener);
54     }
55 }
56