]> git.somenet.org - irc/pjirc-ng.git/blob - src/main/java/irc/AudioConfiguration.java
Pjirc 2.2.1 as available on the net, reformatted and made it compile.
[irc/pjirc-ng.git] / src / main / java / irc / AudioConfiguration.java
1 /*****************************************************/\r
2 /*          This java file is a part of the          */\r
3 /*                                                   */\r
4 /*           -  Plouf's Java IRC Client  -           */\r
5 /*                                                   */\r
6 /*   Copyright (C)  2002 - 2004 Philippe Detournay   */\r
7 /*                                                   */\r
8 /*         All contacts : theplouf@yahoo.com         */\r
9 /*                                                   */\r
10 /*  PJIRC is free software; you can redistribute     */\r
11 /*  it and/or modify it under the terms of the GNU   */\r
12 /*  General Public License as published by the       */\r
13 /*  Free Software Foundation; version 2 or later of  */\r
14 /*  the License.                                     */\r
15 /*                                                   */\r
16 /*  PJIRC is distributed in the hope that it will    */\r
17 /*  be useful, but WITHOUT ANY WARRANTY; without     */\r
18 /*  even the implied warranty of MERCHANTABILITY or  */\r
19 /*  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU   */\r
20 /*  General Public License for more details.         */\r
21 /*                                                   */\r
22 /*  You should have received a copy of the GNU       */\r
23 /*  General Public License along with PJIRC; if      */\r
24 /*  not, write to the Free Software Foundation,      */\r
25 /*  Inc., 59 Temple Place, Suite 330, Boston,        */\r
26 /*  MA  02111-1307  USA                              */\r
27 /*                                                   */\r
28 /*****************************************************/\r
29 \r
30 package irc;\r
31 \r
32 import java.util.Enumeration;\r
33 import java.util.Hashtable;\r
34 \r
35 /**\r
36  * Audio configuration class.\r
37  */\r
38 public class AudioConfiguration {\r
39         private SoundHandler _sound;\r
40 \r
41         private String _query;\r
42         private String _beep;\r
43         private Hashtable _word;\r
44 \r
45         /**\r
46          * Create a new AudioConfiguration, using the given SoundHandler.\r
47          * \r
48          * @param sound\r
49          *          the SoundHandler to use.\r
50          */\r
51         public AudioConfiguration(SoundHandler sound) {\r
52                 _sound = sound;\r
53                 _query = null;\r
54                 _beep = null;\r
55                 _word = new Hashtable();\r
56         }\r
57 \r
58         /**\r
59          * Play the given sound.\r
60          * \r
61          * @param snd\r
62          *          the sound to be played.\r
63          */\r
64         public void play(String snd) {\r
65                 _sound.playSound(snd);\r
66         }\r
67 \r
68         /**\r
69          * Set the query sound.\r
70          * \r
71          * @param snd\r
72          *          sound name.\r
73          */\r
74         public void setQuery(String snd) {\r
75                 _query = snd;\r
76         }\r
77 \r
78         /**\r
79          * Set the beep sound.\r
80          * \r
81          * @param snd\r
82          *          sound name.\r
83          */\r
84         public void setBeep(String snd) {\r
85                 _beep = snd;\r
86         }\r
87 \r
88         /**\r
89          * Set the word sound.\r
90          * \r
91          * @param word\r
92          *          the word.\r
93          * @param snd\r
94          *          the sound to play for the given word.\r
95          */\r
96         public void setWord(String word, String snd) {\r
97                 _word.put(word, snd);\r
98         }\r
99 \r
100         /**\r
101          * Play the sound associated with the new query.\r
102          */\r
103         public void onQuery() {\r
104                 if (_query != null)\r
105                         _sound.playSound(_query);\r
106         }\r
107 \r
108         /**\r
109          * Play the beep sound.\r
110          */\r
111         public void beep() {\r
112                 if (_beep != null)\r
113                         _sound.playSound(_beep);\r
114         }\r
115 \r
116         /**\r
117          * Play the word sound.\r
118          * \r
119          * @param word\r
120          *          word sound to play.\r
121          */\r
122         public void onWord(String word) {\r
123                 String snd = (String) _word.get(word);\r
124                 if (snd != null)\r
125                         _sound.playSound(snd);\r
126         }\r
127 \r
128         /**\r
129          * Get an enumeration of all know sound words.\r
130          * \r
131          * @return an enumeration of string.\r
132          */\r
133         public Enumeration getSoundWords() {\r
134                 return _word.keys();\r
135         }\r
136 }\r