View Javadoc
1 /*** 2 * ExceptionEdge 3 * 4 * This is an edge introduced into the CFG 5 * by an Exception. 6 */ 7 8 package junit.quilt.cover.generic; 9 10 import org.apache.commons.graph.*; 11 import org.apache.bcel.generic.*; 12 13 import junit.quilt.exception.InvalidTransitionException; 14 15 public class ExceptionEdge extends FlowControlEdge 16 { 17 private ObjectType exception = null; 18 19 public ExceptionEdge(BlockVertex source, 20 BlockVertex handler, 21 Class exception) 22 { 23 super( source, handler ); 24 this.exception = new ObjectType( exception.getName() ); 25 } 26 27 public ExceptionEdge(BlockVertex source, 28 BlockVertex handler, 29 ObjectType exception) 30 { 31 super( source, handler ); 32 this.exception = exception; 33 } 34 35 public ExceptionEdge(BlockVertex source, 36 Class exception) 37 { 38 super( source, null ); 39 this.exception = new ObjectType( exception.getName() ); 40 } 41 42 public ExceptionEdge(BlockVertex source, 43 ObjectType exception) 44 { 45 super( source, null ); 46 this.exception = exception; 47 } 48 49 public void connect( MethodGen method, 50 InstructionList il, 51 InstructionHandle source, 52 InstructionHandle target ) 53 { 54 // No handler. 55 if (target == null) { 56 return; 57 } 58 59 if (this.exception == null) { 60 method.addExceptionHandler(source, source, target, 61 null ); // Default Handler. . . 62 } else { 63 method.addExceptionHandler(source, 64 source, 65 target, 66 exception ); 67 } 68 } 69 70 public FlowControlEdge copy( BlockVertex source, 71 BlockVertex target ) { 72 return new ExceptionEdge(source, 73 target, 74 exception); 75 } 76 77 public String toString() { 78 String RC = "[X: "; 79 if (exception == null) { 80 RC = RC + "ALL "; 81 } else { 82 RC = RC + exception; 83 } 84 85 if (getTarget() == null) { 86 RC = RC + " UNHANDLED"; 87 } else { 88 RC = RC + " -> " + getTarget(); 89 } 90 91 RC = RC + "]"; 92 return RC; 93 } 94 }

This page was automatically generated by Maven