View Javadoc
1 package junit.quilt.cover.generic; 2 3 import org.apache.bcel.classfile.LineNumberTable; 4 import org.apache.bcel.generic.*; 5 6 public class EdgeFactoryImpl 7 implements EdgeFactory 8 { 9 public EdgeFactoryImpl() { } 10 11 /*** 12 * makeBranchEdge() 13 * 14 * Override this if you want to have a specific Branch 15 * FlowControlEdge in your graph. 16 * 17 * @param source is the BlockVertex which contains the 18 * branch statement. 19 * 20 * @param target is the target BlockVertex of the branch. 21 * 22 * @param branch will contain as much of a description of the 23 * branch we can get. (i.e. "a < 0") 24 * 25 * @param value is the required value the condition needs to 26 * evaluate to to execute this branch edge. 27 */ 28 public FlowControlEdge makeBranchEdge(BlockVertex source, 29 BlockVertex target, 30 String branch, 31 boolean value) { 32 return new BranchEdge(source, target, branch, value); 33 } 34 35 /*** 36 * makeSelectEdge 37 * 38 * Override this method if you want to make a custom 39 * SelectEdge. 40 * 41 * @param source is the BlockVertex which contains 42 * the Select statement. 43 * 44 * @param target is the BlockVertex which is targeted 45 * by the Select statement. 46 * 47 * @param expr is the expression which is evaluated 48 * for the switch statement. (i.e. "a + b") 49 * 50 * @param value is the integer value which is required 51 * in order to execute this branch. 52 * 53 * (The second version, without the "value" param is 54 * called for the default value. 55 */ 56 public FlowControlEdge makeSelectEdge(BlockVertex source, 57 BlockVertex target, 58 String expr, 59 int value) 60 { 61 return new SelectEdge(source, target, expr, value); 62 } 63 64 public FlowControlEdge makeSelectEdge(BlockVertex source, 65 BlockVertex target, 66 String expr) 67 { 68 return new SelectEdge(source, target, expr); 69 } 70 71 /*** 72 * makeExceptionEdge() 73 * 74 * Override this method if you want to make a special 75 * exception edge. 76 * 77 * @param source is the BlockVertex which contains the 78 * exception thrower. 79 * 80 * @param handler is the BlockVertex which acts as this 81 * exception handler. 82 * 83 * @param exceptions is the set of exceptions which are 84 * caught by the exception handler. 85 * 86 * In the second variation, without the handler, it 87 * represents an unhandled exception. 88 */ 89 public FlowControlEdge makeExceptionEdge(BlockVertex source, 90 BlockVertex handler, 91 Class exception) { 92 return new ExceptionEdge(source, handler, exception); 93 } 94 95 public FlowControlEdge makeExceptionEdge(BlockVertex source, 96 BlockVertex handler, 97 ObjectType exception) { 98 return new ExceptionEdge(source, handler, exception); 99 } 100 101 public FlowControlEdge makeExceptionEdge(BlockVertex source, 102 Class exception) { 103 return new ExceptionEdge(source, exception); 104 } 105 106 public FlowControlEdge makeExceptionEdge(BlockVertex source, 107 ObjectType exception) { 108 return new ExceptionEdge(source, exception); 109 } 110 111 /*** 112 * makeNormalEdge() 113 * 114 * Override this method if you want to make a special 115 * normal edge. 116 * 117 * A Normal Edge is used when there is only normal 118 * flow of control. (No branching or exceptions.) 119 * 120 * Just because you have a normal edge though, does 121 * not mean that the source and target fall under 122 * the same basic block. This edge may very well 123 * be a target from a previous branch. 124 * 125 * @param source is the first BlockVertex in sequence. 126 * @param target is the second BlockVertex in sequence. 127 */ 128 public FlowControlEdge makeNormalEdge(BlockVertex source, 129 BlockVertex target) { 130 return new NormalEdge(source, target); 131 } 132 133 public FlowControlEdge makeDummyEdge(BlockVertex source, 134 BlockVertex target) { 135 return new DummyEdge(source, target); 136 } 137 138 public FlowControlEdge makeJSREdge(BlockVertex source, 139 BlockVertex target) { 140 return new JSREdge(source, target); 141 } 142 143 /*** 144 * makeReturnEdge 145 * 146 * This is called when a Return statement happens. 147 * 148 * @param source is the BlockVertex which contains 149 * the return. 150 */ 151 public FlowControlEdge makeReturnEdge(BlockVertex ret) { 152 return new ReturnEdge(ret); 153 } 154 155 /*** 156 * makeBlockVertex() 157 * 158 * Override this method if you want to provide a special 159 * implementation of a block vertex. 160 * 161 * A BlockVertex represents a collection of OpCodes which 162 * have no branches or exceptions in them. (Except for 163 * the last member of the BlockVertex. 164 * 165 * @param lineNumberTable is the line number table for 166 * the method. It can use this to determine which 167 * lines the block includes. It may be NULL. 168 * 169 * A BlockVertex is responsible for holding all of the 170 * instruction handles in the graph. 171 */ 172 public BlockVertex makeBlockVertex(LineNumberTable lineNumberTable) { 173 return new BlockVertex(lineNumberTable); 174 } 175 176 /*** 177 * makeStartVertex 178 * 179 * This will create a new vertex which acts as 180 * the entry point into the method. 181 * 182 * This gives a location for initialization code. 183 */ 184 public InitVertex makeStartVertex() { 185 return new InitVertex(); 186 } 187 188 /*** 189 * makeEndVertex 190 * 191 * This will create a single exit point from 192 * the graph. This will help us in adding 193 * a finally statement, I believe. 194 */ 195 public FinallyVertex makeEndVertex() { 196 return new FinallyVertex(); 197 } 198 } 199

This page was automatically generated by Maven