30 * <p>Making this an exception instead of a return value forces the user to handle
31 * these case explicitely in a try { ... } catch. The following code illustrates
32 * how this may be done:</p>
33 *
34 * <PRE>
35 * ...
36 * try {
37 * il.delete(start_ih, end_ih);
38 * } catch(TargetLostException e) {
39 * for (InstructionHandle target : e.getTargets()) {
40 * for (InstructionTargeter targeter : target.getTargeters()) {
41 * targeter.updateTarget(target, new_target);
42 * }
43 * }
44 * }
45 * </PRE>
46 *
47 * @see InstructionHandle
48 * @see InstructionList
49 * @see InstructionTargeter
50 * @version $Id$
51 */
52 public final class TargetLostException extends Exception {
53
54 private static final long serialVersionUID = -6857272667645328384L;
55 private final InstructionHandle[] targets;
56
57
58 TargetLostException(final InstructionHandle[] t, final String mesg) {
59 super(mesg);
60 targets = t;
61 }
62
63
64 /**
65 * @return list of instructions still being targeted.
66 */
67 public InstructionHandle[] getTargets() {
68 return targets;
69 }
70 }
|
30 * <p>Making this an exception instead of a return value forces the user to handle
31 * these case explicitely in a try { ... } catch. The following code illustrates
32 * how this may be done:</p>
33 *
34 * <PRE>
35 * ...
36 * try {
37 * il.delete(start_ih, end_ih);
38 * } catch(TargetLostException e) {
39 * for (InstructionHandle target : e.getTargets()) {
40 * for (InstructionTargeter targeter : target.getTargeters()) {
41 * targeter.updateTarget(target, new_target);
42 * }
43 * }
44 * }
45 * </PRE>
46 *
47 * @see InstructionHandle
48 * @see InstructionList
49 * @see InstructionTargeter
50 */
51 public final class TargetLostException extends Exception {
52
53 private static final long serialVersionUID = -6857272667645328384L;
54 private final InstructionHandle[] targets;
55
56
57 TargetLostException(final InstructionHandle[] t, final String mesg) {
58 super(mesg);
59 targets = t;
60 }
61
62
63 /**
64 * @return list of instructions still being targeted.
65 */
66 public InstructionHandle[] getTargets() {
67 return targets;
68 }
69 }
|