01: package method;
02:
03: public class ExtendedExtractMethodTester {
04: public void localVariableTest(int value) {
05: System.out.println("Before what we are extracting. " + value);
06: String keyword = "data";
07: if (value <= 32) {
08: keyword = keyword + "." + value;
09: } else {
10: keyword = keyword + "[" + ((char) value) + "]";
11: }
12: System.out.println("After what we are extracting. " + keyword);
13: }
14:
15: public static String staticMethodTest(String uppercase) {
16: StringBuffer buffer = new StringBuffer();
17:
18: for (int ndx = 0; ndx < uppercase.length(); ndx++) {
19: char ch = uppercase.charAt(ndx);
20: if (ch < 32) {
21: buffer.append("[" + ((int) ch) + "]");
22: } else {
23: buffer.append(Character.toUpperCase(ch));
24: }
25: }
26:
27: return buffer.toString();
28: }
29:
30: private class Pair {
31: private String first;
32: private String second;
33:
34: public void setFirst(String value) {
35: first = value;
36: }
37:
38: public void setSecond(String value) {
39: second = value;
40: }
41:
42: public int computeLength() {
43: int firstValue = 0;
44: firstValue = Integer.parseInt(first.substring(0, 4));
45:
46: int secondValue = 0;
47: secondValue = Integer.parseInt(second.substring(0, 4));
48:
49: return firstValue % secondValue;
50: }
51: }
52: }
|