KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > finalist > jaggenerator > Database


1 /* Copyright (C) 2003 Finalist IT Group
2  *
3  * This file is part of JAG - the Java J2EE Application Generator
4  *
5  * JAG is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  * 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 /**
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 JavaDoc ENTER_DB_NAME = "-- type a name here --";
30
31    private String JavaDoc dbName = ENTER_DB_NAME;
32    private String JavaDoc driverClass;
33    private String JavaDoc typeMapping = DatabaseManagerFrame.SELECT;
34    private String JavaDoc filename;
35
36
37    /**
38     * Gets the human-friendly name of the database.
39     * @return
40     */

41    public String JavaDoc getDbName() {
42       return dbName;
43    }
44
45    public void setDbName(String JavaDoc 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 JavaDoc getDriverClass() {
54       return driverClass;
55    }
56
57    public void setDriverClass(String JavaDoc 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 JavaDoc getTypeMapping() {
68       return typeMapping;
69    }
70
71    public void setTypeMapping(String JavaDoc 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 JavaDoc getFilename() {
81       return filename.replace('\\', '/');
82    }
83
84    public void setFilename(String JavaDoc 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 JavaDoc toString() {
95       if (dbName != null) {
96          return dbName;
97       } else {
98          return driverClass;
99       }
100    }
101
102
103 }
104
Popular Tags