1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package com.finalist.jaggenerator;
18
19 import com.finalist.jaggenerator.modules.DatabaseManagerFrame;
20
21
22 /***
23 * A bean that models a database supported by JAG.
24 *
25 * @author Michael O'Connor - Finalist IT Group
26 */
27 public class Database {
28
29 public static final String ENTER_DB_NAME = "-- type a name here --";
30
31 private String dbName = ENTER_DB_NAME;
32 private String driverClass;
33 private String typeMapping = DatabaseManagerFrame.SELECT;
34 private String filename;
35
36
37 /***
38 * Gets the human-friendly name of the database.
39 * @return
40 */
41 public String getDbName() {
42 return dbName;
43 }
44
45 public void setDbName(String dbName) {
46 this.dbName = dbName;
47 }
48
49 /***
50 * Gets the fully-qualified class name of the JDBC driver class used to access this database.
51 * @return
52 */
53 public String getDriverClass() {
54 return driverClass;
55 }
56
57 public void setDriverClass(String driverClass) {
58 this.driverClass = driverClass;
59 }
60
61 /***
62 * Gets the name of the 'type-mapping' needed by the application server
63 * to know how to map this database's proprietary SQL functions and datatypes to Java.
64 * @return
65 * @todo this property may be application-server specific -maybe better to have a Map of these..?
66 */
67 public String getTypeMapping() {
68 return typeMapping;
69 }
70
71 public void setTypeMapping(String typeMapping) {
72 this.typeMapping = typeMapping;
73 }
74
75 /***
76 * Gets the name (not the full file location) of the file containing the JDBC driver for this database.
77 * <b>NOTE:</b> all instances of the character '\' (backslash) will be replaced by a forward slash!
78 * @return
79 */
80 public String getFilename() {
81 return filename.replace('//', '/');
82 }
83
84 public void setFilename(String filename) {
85 this.filename = filename;
86 }
87
88
89 /***
90 * Display just the database name (used to represent the database in the select drop down list).
91 *
92 * @return just the name.
93 */
94 public String toString() {
95 if (dbName != null) {
96 return dbName;
97 } else {
98 return driverClass;
99 }
100 }
101
102
103 }