1 | |
package test.condition; |
2 | |
|
3 | |
import org.apache.log4j.Logger; |
4 | |
|
5 | 1 | public class ConditionCalls { |
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | 1 | public static String whatEver = null; |
13 | 1 | private static final Logger logger = Logger.getLogger(ConditionCalls.class); |
14 | |
|
15 | |
public void call(int i) |
16 | |
{ |
17 | 1 | if (i>=5) |
18 | |
{ |
19 | |
try |
20 | |
{ |
21 | 1 | logger.error("whatEver"); |
22 | 1 | throw new RuntimeException(); |
23 | |
} |
24 | 1 | catch (Throwable t) |
25 | |
{ |
26 | |
|
27 | |
} |
28 | |
finally |
29 | |
{ |
30 | 1 | System.out.println("true"); |
31 | 1 | } |
32 | |
} else { |
33 | 0 | System.out.println("false"); |
34 | |
} |
35 | 1 | } |
36 | |
|
37 | |
public void callLookupSwitch(int branch) |
38 | |
{ |
39 | 1 | switch (branch) |
40 | |
{ |
41 | |
case 1: |
42 | 1 | System.out.println("1"); |
43 | 1 | break; |
44 | |
case 5: |
45 | 0 | System.out.println("5"); |
46 | 0 | break; |
47 | |
default: |
48 | 0 | System.out.println("default"); |
49 | |
break; |
50 | |
} |
51 | 1 | } |
52 | |
|
53 | |
public String callTableSwitch(int branch) |
54 | |
{ |
55 | |
int[][] multiArray; |
56 | 1 | switch (branch) |
57 | |
{ |
58 | 0 | case 0: return("0"); |
59 | 0 | case 1: return("1"); |
60 | 0 | case 2: return("2"); |
61 | 0 | case 3: return("3"); |
62 | 0 | case 4: return("4"); |
63 | 0 | case 5: return("5"); |
64 | 0 | case 6: return("6"); |
65 | 0 | case 7: return("7"); |
66 | 0 | case 8: return("8"); |
67 | 1 | default: multiArray = new int[3][3]; return("" + multiArray[1][1]); |
68 | |
} |
69 | |
} |
70 | |
|
71 | |
public void callMultiCondition(int a, int b, int c) |
72 | |
{ |
73 | |
|
74 | 1 | if ((a == b) && (b >= 3) || (c++ < a)) |
75 | |
{ |
76 | 1 | System.out.println("true"); |
77 | |
} |
78 | 1 | } |
79 | |
|
80 | |
public void callMultiCondition2(int a, int b, int c) |
81 | |
{ |
82 | 1 | if ((a == b) && (b >= utilEcho(3)) || (c < a)) |
83 | |
{ |
84 | 1 | System.out.println("true"); |
85 | |
} |
86 | 1 | } |
87 | |
|
88 | |
int utilEcho(int number) |
89 | |
{ |
90 | 1 | return number; |
91 | |
} |
92 | |
|
93 | |
static |
94 | |
{ |
95 | 1 | whatEver = "whatEver"; |
96 | 1 | }; |
97 | |
|
98 | |
public static final int CALL_CONDITION_LINE_NUMBER = 17; |
99 | |
public static final int CALL_IGNORE_LINE_NUMBER = 21; |
100 | |
public static final int LOOKUP_SWITCH_LINE_NUMBER = 39; |
101 | |
public static final int TABLE_SWITCH_LINE_NUMBER = 56; |
102 | |
public static final int MULTI_CONDITION_LINE_NUMBER = 74; |
103 | |
public static final int MULTI_CONDITION2_LINE_NUMBER = 82; |
104 | |
} |