01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package javax.sound.sampled;
19:
20: import org.apache.harmony.sound.internal.nls.Messages;
21:
22: public abstract class EnumControl extends Control {
23: public static class Type extends Control.Type {
24: public static final Type REVERB = new Type("Reverb"); //$NON-NLS-1$
25:
26: protected Type(String name) {
27: super (name);
28: }
29: }
30:
31: private Object[] values;
32:
33: private Object value;
34:
35: protected EnumControl(EnumControl.Type type, Object[] values,
36: Object value) {
37: super (type);
38: this .value = value;
39: this .values = values;
40: }
41:
42: public void setValue(Object value) {
43: for (Object val : values) {
44: if (val.equals(value)) {
45: this .value = value;
46: return;
47: }
48: }
49: // sound.0D=The value is not supported
50: throw new IllegalArgumentException(Messages
51: .getString("sound.0D")); //$NON-NLS-1$
52: }
53:
54: public Object getValue() {
55: return value;
56: }
57:
58: public Object[] getValues() {
59: return values;
60: }
61:
62: public String toString() {
63: return getType() + " with current value: " + value; //$NON-NLS-1$
64: }
65: }
|