View Javadoc

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   * <B>ConstructorWrapper </B>. Constructorをラッピングするクラスです。
12   * 
13   * @see java.lang.reflect.Constructor
14   * @author $Author: wildcats $
15   * @version $Revision: 5 $
16   */
17  public class ConstructorWrapper {
18  
19      private Constructor constructor;
20  
21      private ConstructorWrapper() {
22      }
23  
24      public ConstructorWrapper(Constructor constructor) {
25          this.constructor = constructor;
26      }
27  
28      public Constructor get() {
29          return this.constructor;
30      }
31  
32      public Object newInstance() {
33          return this.newInstance(new Object[] {});
34      }
35  
36      public Object newInstance(Object[] objects) {
37          Object result = null;
38          try {
39              result = this.constructor.newInstance(objects);
40          } catch (java.lang.IllegalArgumentException e) {
41              throw new IllegalArgumentExceptionWrapper(e);
42          } catch (java.lang.InstantiationException e) {
43              throw new InstantiationExceptionWrapper(e);
44          } catch (java.lang.IllegalAccessException e) {
45              throw new IllegalAccessExceptionWrapper(e);
46          } catch (java.lang.reflect.InvocationTargetException e) {
47              throw new InvocationTargetExceptionWrapper(e);
48          }
49          return result;
50      }
51  
52      /***
53       * @see java.lang.Object#toString()
54       */
55      public String toString() {
56          StringBuffer sb = new StringBuffer(this.getClass().getName());
57          sb.append(":");
58          sb.append(constructor.getName());
59          return sb.toString();
60      }
61  
62  }