source: trunk/src_apollo/org/apollo/audio/structure/TrackGraphLoopException.java@ 315

Last change on this file since 315 was 315, checked in by bjn8, 16 years ago

Apollo spin-off added

File size: 1.2 KB
Line 
1package org.apollo.audio.structure;
2
3import java.util.Stack;
4
5/**
6 * Raised when a track graph contains a loop. Provide loop trace information.
7 *
8 * @author Brook Novak
9 *
10 */
11public class TrackGraphLoopException extends Exception {
12
13
14 private static final long serialVersionUID = 1L;
15
16 private Stack<OverdubbedFrame> loopTrace;
17
18 public TrackGraphLoopException(Stack<OverdubbedFrame> loopTrace) {
19 if (loopTrace == null) {
20 loopTrace = new Stack<OverdubbedFrame>();
21 } else this.loopTrace = loopTrace;
22 }
23
24 /**
25 * The full loop trace ... from where the start of
26 * the loop checker began
27 *
28 * @return
29 * The loop trace. Never null.
30 */
31 public Stack<OverdubbedFrame> getFullLoopTrace() {
32 return loopTrace;
33 }
34
35 @Override
36 public String getLocalizedMessage() {
37 StringBuilder sb = new StringBuilder("Contains loop ");
38
39 String causeFrameName = loopTrace.lastElement().getFrameName();
40 boolean mentionedLoopStart = false;
41
42 for (OverdubbedFrame odf : loopTrace) {
43 sb.append("\n\t\tat ");
44 sb.append(odf);
45
46 if (!mentionedLoopStart && odf.getFrameName().equals(causeFrameName)) {
47 sb.append("\t --- Loop starts here ---");
48 mentionedLoopStart = true;
49 }
50 }
51
52 return sb.toString();
53 }
54
55
56
57
58
59}
Note: See TracBrowser for help on using the repository browser.