1 7 8 package javax.sound.sampled; 9 10 31 public class LineEvent extends java.util.EventObject { 32 33 35 41 private final Type type; 42 43 53 private final long position; 54 55 56 66 public LineEvent(Line line, Type type, long position) { 67 68 super(line); 69 this.type = type; 70 this.position = position; 71 } 72 73 77 public final Line getLine() { 78 79 return (Line )getSource(); 80 } 81 82 83 88 public final Type getType() { 89 90 return type; 91 } 92 93 107 111 public final long getFramePosition() { 112 113 return position; 114 } 115 116 121 public String toString() { 122 String sType = ""; 123 if (type != null) sType = type.toString()+" "; 124 String sLine; 125 if (getLine() == null) { 126 sLine = "null"; 127 } else { 128 sLine = getLine().toString(); 129 } 130 return new String (sType + "event from line " + sLine); 131 } 132 133 134 140 public static class Type { 141 142 143 146 private String name; 148 149 153 protected Type(String name) { 154 this.name = name; 155 } 156 157 158 166 public final boolean equals(Object obj) { 167 return super.equals(obj); 168 } 169 170 171 174 public final int hashCode() { 175 return super.hashCode(); 176 } 177 178 179 182 public String toString() { 183 return name; 184 } 185 186 187 189 195 public static final Type OPEN = new Type("Open"); 196 197 198 204 public static final Type CLOSE = new Type("Close"); 205 206 207 214 public static final Type START = new Type("Start"); 215 216 217 224 public static final Type STOP = new Type("Stop"); 225 226 227 231 238 240 241 251 253 254 260 262 } 264 } | Popular Tags |