001: /*
002: Copyright (C) 2003 Know Gate S.L. All rights reserved.
003: C/Oņa, 107 1š2 28050 Madrid (Spain)
004:
005: Redistribution and use in source and binary forms, with or without
006: modification, are permitted provided that the following conditions
007: are met:
008:
009: 1. Redistributions of source code must retain the above copyright
010: notice, this list of conditions and the following disclaimer.
011:
012: 2. The end-user documentation included with the redistribution,
013: if any, must include the following acknowledgment:
014: "This product includes software parts from hipergate
015: (http://www.hipergate.org/)."
016: Alternately, this acknowledgment may appear in the software itself,
017: if and wherever such third-party acknowledgments normally appear.
018:
019: 3. The name hipergate must not be used to endorse or promote products
020: derived from this software without prior written permission.
021: Products derived from this software may not be called hipergate,
022: nor may hipergate appear in their name, without prior written
023: permission.
024:
025: This library is distributed in the hope that it will be useful,
026: but WITHOUT ANY WARRANTY; without even the implied warranty of
027: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
028:
029: You should have received a copy of hipergate License with this code;
030: if not, visit http://www.hipergate.org or mail to info@hipergate.org
031: */
032:
033: package com.knowgate.dataobjs;
034:
035: /**
036: * @author Sergio Montoro Ten
037: * @version 1.0
038: */
039:
040: import com.knowgate.dataobjs.DBBind;
041:
042: import java.awt.Image;
043:
044: import java.lang.ClassNotFoundException;
045: import java.lang.NoSuchMethodException;
046:
047: import java.beans.SimpleBeanInfo;
048: import java.beans.BeanDescriptor;
049: import java.beans.MethodDescriptor;
050:
051: public class DBBindBeanInfo extends SimpleBeanInfo {
052:
053: public DBBindBeanInfo() {
054: }
055:
056: public BeanDescriptor getBeanDescriptor() {
057: return new BeanDescriptor(beanClass);
058: }
059:
060: public Image getIcon(int iconKind) {
061: switch (iconKind) {
062: case SimpleBeanInfo.ICON_MONO_16x16:
063: return loadImage("dbbind16m.gif");
064: case SimpleBeanInfo.ICON_COLOR_16x16:
065: return loadImage("dbbind16c.gif");
066: case SimpleBeanInfo.ICON_MONO_32x32:
067: return loadImage("dbbind32m.gif");
068: case SimpleBeanInfo.ICON_COLOR_32x32:
069: return loadImage("dbbind32c.gif");
070: }
071: return null;
072: }
073:
074: public MethodDescriptor[] getMethodDescriptors() {
075: try {
076: Class voidParams[] = {};
077: Class nextValParams[] = {
078: Class.forName("java.sql.Connection"),
079: Class.forName("String") };
080: Class getTableParams[] = { Class.forName("String") };
081: Class getConnectionParams[] = { Class.forName("String") };
082: Class escapeParams[] = { Class.forName("java.util.Date"),
083: Class.forName("String") };
084: Class existsParams[] = {
085: Class.forName("com.knowgate.jdc.JDCConnection"),
086: Class.forName("String"), Class.forName("String") };
087: Class getDataModelParams[] = { Class
088: .forName("com.knowgate.jdc.JDCConnection") };
089:
090: MethodDescriptor closeBind = new MethodDescriptor(
091: DBBind.class.getMethod("close", voidParams));
092: MethodDescriptor nextVal = new MethodDescriptor(
093: DBBind.class.getMethod("nextVal", nextValParams));
094: MethodDescriptor getTable = new MethodDescriptor(
095: DBBind.class.getMethod("getTable", getTableParams));
096: MethodDescriptor getConnection = new MethodDescriptor(
097: DBBind.class.getMethod("getConnection",
098: getConnectionParams));
099: MethodDescriptor getDataModelVersion = new MethodDescriptor(
100: DBBind.class.getMethod("getDatabaseProductName",
101: getDataModelParams));
102: MethodDescriptor getDataModelVersionNumber = new MethodDescriptor(
103: DBBind.class.getMethod("getDatabaseProductName",
104: getDataModelParams));
105: MethodDescriptor getDatabaseProductName = new MethodDescriptor(
106: DBBind.class.getMethod("getDatabaseProductName",
107: voidParams));
108: MethodDescriptor getTime = new MethodDescriptor(
109: DBBind.class.getMethod("getTime", voidParams));
110: MethodDescriptor connectionPool = new MethodDescriptor(
111: DBBind.class
112: .getMethod("connectionPool", voidParams));
113: MethodDescriptor escape = new MethodDescriptor(DBBind.class
114: .getMethod("escape", escapeParams));
115: MethodDescriptor exists = new MethodDescriptor(DBBind.class
116: .getMethod("exists", voidParams));
117:
118: MethodDescriptor rv[] = { closeBind, nextVal, getTable,
119: getConnection, getDataModelVersion,
120: getDataModelVersionNumber, getDatabaseProductName,
121: getTime, connectionPool, escape, exists };
122: return rv;
123: } catch (ClassNotFoundException e) {
124: throw new Error(e.toString());
125: } catch (NoSuchMethodException e) {
126: throw new Error(e.toString());
127: }
128: }
129:
130: private final static Class beanClass = DBBind.class;
131: }
|