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: public interface Port extends Line {
21:
22: public static class Info extends Line.Info {
23:
24: private String name;
25:
26: private boolean isSource;
27:
28: public static final Info MICROPHONE = new Info(Port.class,
29: "MICROPHONE", true); //$NON-NLS-1$
30:
31: public static final Info LINE_IN = new Info(Port.class,
32: "LINE_IN", true); //$NON-NLS-1$
33:
34: public static final Info COMPACT_DISC = new Info(Port.class,
35: "COMPACT_DISC", true); //$NON-NLS-1$
36:
37: public static final Info SPEAKER = new Info(Port.class,
38: "SPEAKER", //$NON-NLS-1$
39: false);
40:
41: public static final Info HEADPHONE = new Info(Port.class,
42: "HEADPHONES", //$NON-NLS-1$
43: false);
44:
45: public static final Info LINE_OUT = new Info(Port.class,
46: "LINE_OUT", //$NON-NLS-1$
47: false);
48:
49: public Info(Class<?> lineClass, String name, boolean isSource) {
50: super (lineClass);
51: this .name = name;
52: this .isSource = isSource;
53: }
54:
55: public String getName() {
56: return this .name;
57: }
58:
59: public boolean isSource() {
60: return this .isSource;
61: }
62:
63: public boolean matches(Line.Info info) {
64: if (super .matches(info)
65: && Port.Info.class.equals(info.getClass())
66: && name.equals(((Port.Info) info).getName())
67: && isSource == ((Port.Info) info).isSource()) {
68: return true;
69: }
70: return false;
71: }
72:
73: public final boolean equals(Object obj) {
74: return this == obj;
75: }
76:
77: public final int hashCode() {
78: return name.hashCode() ^ getLineClass().hashCode();
79: }
80:
81: public final String toString() {
82: return name + (isSource ? " source port" : " target port"); //$NON-NLS-1$ //$NON-NLS-2$
83: }
84: }
85: }
|