01: /* Copyright (C) 2003 Finalist IT Group
02: *
03: * This file is part of JAG - the Java J2EE Application Generator
04: *
05: * JAG is free software; you can redistribute it and/or modify
06: * it under the terms of the GNU General Public License as published by
07: * the Free Software Foundation; either version 2 of the License, or
08: * (at your option) any later version.
09: * JAG is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12: * GNU General Public License for more details.
13: * You should have received a copy of the GNU General Public License
14: * along with JAG; if not, write to the Free Software
15: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16: */
17: package com.finalist.jaggenerator;
18:
19: import com.finalist.jaggenerator.modules.DatabaseManagerFrame;
20:
21: /**
22: * A bean that models a database supported by JAG.
23: *
24: * @author Michael O'Connor - Finalist IT Group
25: */
26: public class Database {
27:
28: public static final String ENTER_DB_NAME = "-- type a name here --";
29:
30: private String dbName = ENTER_DB_NAME;
31: private String driverClass;
32: private String typeMapping = DatabaseManagerFrame.SELECT;
33: private String filename;
34:
35: /**
36: * Gets the human-friendly name of the database.
37: * @return
38: */
39: public String getDbName() {
40: return dbName;
41: }
42:
43: public void setDbName(String dbName) {
44: this .dbName = dbName;
45: }
46:
47: /**
48: * Gets the fully-qualified class name of the JDBC driver class used to access this database.
49: * @return
50: */
51: public String getDriverClass() {
52: return driverClass;
53: }
54:
55: public void setDriverClass(String driverClass) {
56: this .driverClass = driverClass;
57: }
58:
59: /**
60: * Gets the name of the 'type-mapping' needed by the application server
61: * to know how to map this database's proprietary SQL functions and datatypes to Java.
62: * @return
63: * @todo this property may be application-server specific -maybe better to have a Map of these..?
64: */
65: public String getTypeMapping() {
66: return typeMapping;
67: }
68:
69: public void setTypeMapping(String typeMapping) {
70: this .typeMapping = typeMapping;
71: }
72:
73: /**
74: * Gets the name (not the full file location) of the file containing the JDBC driver for this database.
75: * <b>NOTE:</b> all instances of the character '\' (backslash) will be replaced by a forward slash!
76: * @return
77: */
78: public String getFilename() {
79: return filename.replace('\\', '/');
80: }
81:
82: public void setFilename(String filename) {
83: this .filename = filename;
84: }
85:
86: /**
87: * Display just the database name (used to represent the database in the select drop down list).
88: *
89: * @return just the name.
90: */
91: public String toString() {
92: if (dbName != null) {
93: return dbName;
94: } else {
95: return driverClass;
96: }
97: }
98:
99: }
|