File: MethodSelection.java

package info (click to toggle)
bsh 1.1alpha5-1
  • links: PTS
  • area: contrib
  • in suites: woody
  • size: 2,336 kB
  • ctags: 2,083
  • sloc: java: 16,095; makefile: 134; sh: 51
file content (98 lines) | stat: -rw-r--r-- 2,529 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98

public class MethodSelection {

	public Class constructedWith;

	// constructors 

	public MethodSelection( Object o ) {
		constructedWith = o.getClass();
		System.out.println("selected object constr");
	}
	public MethodSelection( String o ) {
		constructedWith = o.getClass();
		System.out.println("selected string constr");
	}
	public MethodSelection( long o ) {
		constructedWith = Long.TYPE;
		System.out.println("selected long constr");
	}
	public MethodSelection( int o ) {
		constructedWith = Integer.TYPE;
		System.out.println("selected int constr");
	}
	public MethodSelection( byte o ) {
		constructedWith = Byte.TYPE;
		System.out.println("selected byte constr");
	}
	public MethodSelection( short o ) {
		constructedWith = Short.TYPE;
		System.out.println("selected short constr");
	}
	public MethodSelection() {
		constructedWith = Void.TYPE;
		System.out.println("no args constr");
	}

	// static method selection

	public static Class get_static( Object o ) {
		System.out.println("selected object method");
		return o.getClass();
	}
	public static Class get_static( String o ) {
		System.out.println("selected string method");
		return o.getClass();
	}
	public static Class get_static( int o ) {
		System.out.println("selected int method");
		return Integer.TYPE;
	}
	public static Class get_static( long o ) {
		System.out.println("selected long method");
		return Long.TYPE;
	}
	public static Class get_static( byte o ) {
		System.out.println("selected byte method");
		return Byte.TYPE;
	}
	public static Class get_static( short o ) {
		System.out.println("selected short method");
		return Short.TYPE;
	}
	public static Class get_static() {
		System.out.println("selected no args method");
		return Void.TYPE;
	}

	// dynamic method selection

	public Class get_dynamic( Object o ) {
		System.out.println("selected object method");
		return o.getClass();
	}
	public Class get_dynamic( String o ) {
		System.out.println("selected string method");
		return o.getClass();
	}
	public Class get_dynamic( int o ) {
		System.out.println("selected int method");
		return Integer.TYPE;
	}
	public Class get_dynamic( long o ) {
		System.out.println("selected long method");
		return Long.TYPE;
	}
	public Class get_dynamic( byte o ) {
		System.out.println("selected byte method");
		return Byte.TYPE;
	}
	public Class get_dynamic( short o ) {
		System.out.println("selected short method");
		return Short.TYPE;
	}
	public Class get_dynamic() {
		System.out.println("selected no args method");
		return Void.TYPE;
	}
}