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     /***
139      * Create an edge for JSR to a subroutine.
140      */
141     public FlowControlEdge makeJSREdge(BlockVertex source,
142 			       BlockVertex target) {
143 	return new JSREdge(source, target);
144     }
145     
146     /***
147      * makeReturnEdge
148      *
149      * This is called when a Return statement happens.
150      *
151      * @param source is the BlockVertex which contains
152      * the return.
153      */
154     public FlowControlEdge makeReturnEdge(BlockVertex ret) {
155 	return new ReturnEdge(ret);
156     }
157 
158     /***
159      * makeBlockVertex()
160      *
161      * Override this method if you want to provide a special
162      * implementation of a block vertex.
163      *
164      * A BlockVertex represents a collection of OpCodes which
165      * have no branches or exceptions in them.  (Except for
166      * the last member of the BlockVertex.
167      *
168      * @param lineNumberTable is the line number table for
169      * the method.  It can use this to determine which
170      * lines the block includes.  It may be NULL.
171      *
172      * A BlockVertex is responsible for holding all of the
173      * instruction handles in the graph.
174      */
175     public BlockVertex makeBlockVertex(LineNumberTable lineNumberTable) {
176 	return new BlockVertex(lineNumberTable);
177     }
178 
179     /***
180      * makeStartVertex
181      *
182      * This will create a new vertex which acts as
183      * the entry point into the method.
184      *
185      * This gives a location for initialization code.
186      */
187     public InitVertex makeStartVertex() {
188 	return new InitVertex();
189     }
190 
191     /***
192      * makeEndVertex
193      *
194      * This will create a single exit point from
195      * the graph.  This will help us in adding
196      * a finally statement, I believe.
197      */
198     public FinallyVertex makeEndVertex() {
199 	return new FinallyVertex();
200     }
201 }
202 
This page was automatically generated by Maven