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 java.util.EventObject;
21:
22: public class LineEvent extends EventObject {
23:
24: /**
25: *
26: */
27: private static final long serialVersionUID = -1274246333383880410L;
28:
29: private LineEvent.Type type;
30: private long position;
31:
32: public static class Type {
33:
34: public static final Type CLOSE = new Type("Close"); //$NON-NLS-1$
35:
36: public static final Type OPEN = new Type("Open"); //$NON-NLS-1$
37:
38: public static final Type START = new Type("Start"); //$NON-NLS-1$
39:
40: public static final Type STOP = new Type("Stop"); //$NON-NLS-1$
41:
42: private String name;
43:
44: protected Type(String name) {
45: this .name = name;
46: }
47:
48: @Override
49: public final boolean equals(Object another) {
50: if (this == another) {
51: return true;
52: }
53:
54: if (another == null || !(another instanceof Type)) {
55: return false;
56: }
57:
58: Type obj = (Type) another;
59: return name == null ? obj.name == null : name
60: .equals(obj.name);
61: }
62:
63: @Override
64: public final int hashCode() {
65: return name == null ? 0 : name.hashCode();
66: }
67:
68: @Override
69: public String toString() {
70: return name;
71: }
72: }
73:
74: public LineEvent(Line line, LineEvent.Type type, long position) {
75: super (line);
76: this .type = type;
77: this .position = position;
78: }
79:
80: public final Line getLine() {
81: return (Line) getSource();
82: }
83:
84: public final LineEvent.Type getType() {
85: return type;
86: }
87:
88: public final long getFramePosition() {
89: return position;
90: }
91:
92: public String toString() {
93: return type + " event from line " + getLine(); //$NON-NLS-1$
94: }
95: }
|