1 /* 2 Copyright (C) 2005 Free Software Foundation, Inc. 3 4 This file is part of GNU Classpath. 5 6 GNU Classpath is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 2, or (at your option) 9 any later version. 10 11 GNU Classpath is distributed in the hope that it will be useful, but 12 WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with GNU Classpath; see the file COPYING. If not, write to the 18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 19 02110-1301 USA. 20 21 Linking this library statically or dynamically with other modules is 22 making a combined work based on this library. Thus, the terms and 23 conditions of the GNU General Public License cover the whole 24 combination. 25 26 As a special exception, the copyright holders of this library give you 27 permission to link this library with independent modules to produce an 28 executable, regardless of the license terms of these independent 29 modules, and to copy and distribute the resulting executable under 30 terms of your choice, provided that you also meet, for each linked 31 independent module, the terms and conditions of the license of that 32 module. An independent module is a module which is not derived from 33 or based on this library. If you modify this library, you may extend 34 this exception to your version of the library, but you are not 35 obligated to do so. If you do not wish to do so, delete this 36 exception statement from your version. */ 37 38 39 package javax.sound.sampled; 40 41 import java.io.IOException; 42 import java.io.NotSerializableException; 43 import java.io.ObjectInputStream; 44 import java.io.ObjectOutputStream; 45 import java.util.EventObject; 46 47 /** 48 * This class holds information about a state change of a Line. 49 * @specnote This class is not really serializable, and attempts to 50 * serialize it will throw {@link NotSerializableException}. 51 * @since 1.3 52 */ 53 public class LineEvent extends EventObject 54 { 55 // We define this even though this class can't be serialized, in 56 // order to placate the compiler. 57 private static final long serialVersionUID = -1274246333383880410L; 58 59 /** 60 * This class represents the kinds of state changes that can occur 61 * to a Line. The standard states are availabe as static instances. 62 * @since 1.3 63 */ 64 public static class Type 65 { 66 /** An event of this type is posted when a Line closes. */ 67 public static final Type CLOSE = new Type("close"); 68 69 /** An event of this type is posted when a Line opens. */ 70 public static final Type OPEN = new Type("open"); 71 72 /** An event of this type is posted when a Line starts. */ 73 public static final Type START = new Type("start"); 74 75 /** An event of this type is posted when a Line stops. */ 76 public static final Type STOP = new Type("stop"); 77 78 private String name; 79 80 /** 81 * Create a new type with the indicated name. 82 * @param name the name 83 */ Type(String name)84 protected Type(String name) 85 { 86 this.name = name; 87 } 88 equals(Object o)89 public final boolean equals(Object o) 90 { 91 return super.equals(o); 92 } 93 hashCode()94 public final int hashCode() 95 { 96 return super.hashCode(); 97 } 98 99 /** 100 * Return the name of this Type. 101 */ toString()102 public String toString() 103 { 104 return name; 105 } 106 } 107 108 private Type type; 109 private long framePosition; 110 private Line line; 111 112 /** 113 * Create a new LineEvent with the indicated line, type, and frame position. 114 * @param line the line 115 * @param type the type of the event 116 * @param pos the frame position 117 */ LineEvent(Line line, Type type, long pos)118 public LineEvent(Line line, Type type, long pos) 119 { 120 super(line); 121 this.line = line; 122 this.type = type; 123 this.framePosition = pos; 124 } 125 126 /** 127 * Return the frame position associated with this event. 128 */ getFramePosition()129 public final long getFramePosition() 130 { 131 return framePosition; 132 } 133 134 /** 135 * Return the Line associated with this event. 136 */ getLine()137 public final Line getLine() 138 { 139 return line; 140 } 141 142 /** 143 * Return the Type associated with this event. 144 */ getType()145 public final Type getType() 146 { 147 return type; 148 } 149 150 /** 151 * Return a description of this event. 152 */ toString()153 public String toString() 154 { 155 return ("type=" + type + "; framePosition=" + framePosition 156 + "line=" + line); 157 } 158 readObject(ObjectInputStream ois)159 private void readObject(ObjectInputStream ois) 160 throws IOException 161 { 162 throw new NotSerializableException("LineEvent is not serializable"); 163 } 164 writeObject(ObjectOutputStream oos)165 private void writeObject(ObjectOutputStream oos) 166 throws IOException 167 { 168 throw new NotSerializableException("LineEvent is not serializable"); 169 } 170 } 171