KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > knowgate > dataobjs > DBBindBeanInfo


1 /*
2   Copyright (C) 2003 Know Gate S.L. All rights reserved.
3                       C/Oņa, 107 1š2 28050 Madrid (Spain)
4
5   Redistribution and use in source and binary forms, with or without
6   modification, are permitted provided that the following conditions
7   are met:
8
9   1. Redistributions of source code must retain the above copyright
10      notice, this list of conditions and the following disclaimer.
11
12   2. The end-user documentation included with the redistribution,
13      if any, must include the following acknowledgment:
14      "This product includes software parts from hipergate
15      (http://www.hipergate.org/)."
16      Alternately, this acknowledgment may appear in the software itself,
17      if and wherever such third-party acknowledgments normally appear.
18
19   3. The name hipergate must not be used to endorse or promote products
20      derived from this software without prior written permission.
21      Products derived from this software may not be called hipergate,
22      nor may hipergate appear in their name, without prior written
23      permission.
24
25   This library is distributed in the hope that it will be useful,
26   but WITHOUT ANY WARRANTY; without even the implied warranty of
27   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
28
29   You should have received a copy of hipergate License with this code;
30   if not, visit http://www.hipergate.org or mail to info@hipergate.org
31 */

32
33 package com.knowgate.dataobjs;
34
35 /**
36  * @author Sergio Montoro Ten
37  * @version 1.0
38  */

39
40 import com.knowgate.dataobjs.DBBind;
41
42 import java.awt.Image JavaDoc;
43
44 import java.lang.ClassNotFoundException JavaDoc;
45 import java.lang.NoSuchMethodException JavaDoc;
46
47 import java.beans.SimpleBeanInfo JavaDoc;
48 import java.beans.BeanDescriptor JavaDoc;
49 import java.beans.MethodDescriptor JavaDoc;
50
51 public class DBBindBeanInfo extends SimpleBeanInfo JavaDoc {
52
53   public DBBindBeanInfo() {
54   }
55
56   public BeanDescriptor JavaDoc getBeanDescriptor() {
57     return new BeanDescriptor JavaDoc(beanClass);
58   }
59
60   public Image JavaDoc getIcon(int iconKind) {
61     switch(iconKind) {
62       case SimpleBeanInfo.ICON_MONO_16x16:
63         return loadImage("dbbind16m.gif");
64       case SimpleBeanInfo.ICON_COLOR_16x16:
65         return loadImage("dbbind16c.gif");
66       case SimpleBeanInfo.ICON_MONO_32x32:
67         return loadImage("dbbind32m.gif");
68       case SimpleBeanInfo.ICON_COLOR_32x32:
69         return loadImage("dbbind32c.gif");
70     }
71   return null;
72   }
73
74   public MethodDescriptor JavaDoc[] getMethodDescriptors() {
75     try {
76         Class JavaDoc voidParams[] = { };
77         Class JavaDoc nextValParams[] = { Class.forName("java.sql.Connection"), Class.forName("String") };
78         Class JavaDoc getTableParams[] = { Class.forName("String") };
79         Class JavaDoc getConnectionParams[] = { Class.forName("String") };
80         Class JavaDoc escapeParams[] = { Class.forName("java.util.Date"), Class.forName("String") };
81         Class JavaDoc existsParams[] = { Class.forName("com.knowgate.jdc.JDCConnection"), Class.forName("String"), Class.forName("String") };
82         Class JavaDoc getDataModelParams[] = { Class.forName("com.knowgate.jdc.JDCConnection") };
83
84         MethodDescriptor JavaDoc closeBind =
85             new MethodDescriptor JavaDoc(DBBind.class.getMethod("close", voidParams));
86         MethodDescriptor JavaDoc nextVal =
87             new MethodDescriptor JavaDoc(DBBind.class.getMethod("nextVal", nextValParams));
88         MethodDescriptor JavaDoc getTable =
89             new MethodDescriptor JavaDoc(DBBind.class.getMethod("getTable", getTableParams));
90         MethodDescriptor JavaDoc getConnection =
91             new MethodDescriptor JavaDoc(DBBind.class.getMethod("getConnection", getConnectionParams));
92         MethodDescriptor JavaDoc getDataModelVersion =
93             new MethodDescriptor JavaDoc(DBBind.class.getMethod("getDatabaseProductName", getDataModelParams));
94         MethodDescriptor JavaDoc getDataModelVersionNumber =
95             new MethodDescriptor JavaDoc(DBBind.class.getMethod("getDatabaseProductName", getDataModelParams));
96         MethodDescriptor JavaDoc getDatabaseProductName =
97             new MethodDescriptor JavaDoc(DBBind.class.getMethod("getDatabaseProductName", voidParams));
98         MethodDescriptor JavaDoc getTime =
99             new MethodDescriptor JavaDoc(DBBind.class.getMethod("getTime", voidParams));
100         MethodDescriptor JavaDoc connectionPool =
101             new MethodDescriptor JavaDoc(DBBind.class.getMethod("connectionPool", voidParams));
102         MethodDescriptor JavaDoc escape =
103             new MethodDescriptor JavaDoc(DBBind.class.getMethod("escape", escapeParams));
104         MethodDescriptor JavaDoc exists =
105             new MethodDescriptor JavaDoc(DBBind.class.getMethod("exists", voidParams));
106
107         MethodDescriptor JavaDoc rv[] = { closeBind, nextVal, getTable, getConnection,
108             getDataModelVersion, getDataModelVersionNumber, getDatabaseProductName,
109             getTime, connectionPool, escape, exists };
110         return rv;
111     } catch (ClassNotFoundException JavaDoc e) {
112          throw new Error JavaDoc(e.toString());
113     } catch (NoSuchMethodException JavaDoc e) {
114          throw new Error JavaDoc(e.toString());
115     }
116   }
117
118   private final static Class JavaDoc beanClass = DBBind.class;
119 }
120
Popular Tags