1 |
|
package com.wikihouse.wildcats0201.jdbcchart.reflectionutil; |
2 |
|
|
3 |
|
import java.lang.reflect.Constructor; |
4 |
|
|
5 |
|
import com.wikihouse.wildcats0201.jdbcchart.reflectionutil.exception.IllegalAccessExceptionWrapper; |
6 |
|
import com.wikihouse.wildcats0201.jdbcchart.reflectionutil.exception.IllegalArgumentExceptionWrapper; |
7 |
|
import com.wikihouse.wildcats0201.jdbcchart.reflectionutil.exception.InstantiationExceptionWrapper; |
8 |
|
import com.wikihouse.wildcats0201.jdbcchart.reflectionutil.exception.InvocationTargetExceptionWrapper; |
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
public class ConstructorWrapper { |
18 |
|
|
19 |
|
private Constructor constructor; |
20 |
|
|
21 |
0 |
private ConstructorWrapper() { |
22 |
0 |
} |
23 |
|
|
24 |
6 |
public ConstructorWrapper(Constructor constructor) { |
25 |
6 |
this.constructor = constructor; |
26 |
6 |
} |
27 |
|
|
28 |
|
public Constructor get() { |
29 |
12 |
return this.constructor; |
30 |
|
} |
31 |
|
|
32 |
|
public Object newInstance() { |
33 |
0 |
return this.newInstance(new Object[] {}); |
34 |
|
} |
35 |
|
|
36 |
|
public Object newInstance(Object[] objects) { |
37 |
0 |
Object result = null; |
38 |
|
try { |
39 |
0 |
result = this.constructor.newInstance(objects); |
40 |
0 |
} catch (java.lang.IllegalArgumentException e) { |
41 |
0 |
throw new IllegalArgumentExceptionWrapper(e); |
42 |
|
} catch (java.lang.InstantiationException e) { |
43 |
0 |
throw new InstantiationExceptionWrapper(e); |
44 |
|
} catch (java.lang.IllegalAccessException e) { |
45 |
0 |
throw new IllegalAccessExceptionWrapper(e); |
46 |
|
} catch (java.lang.reflect.InvocationTargetException e) { |
47 |
0 |
throw new InvocationTargetExceptionWrapper(e); |
48 |
|
} |
49 |
0 |
return result; |
50 |
|
} |
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
public String toString() { |
56 |
0 |
StringBuffer sb = new StringBuffer(this.getClass().getName()); |
57 |
0 |
sb.append(":"); |
58 |
0 |
sb.append(constructor.getName()); |
59 |
0 |
return sb.toString(); |
60 |
|
} |
61 |
|
|
62 |
|
} |