001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.visualweb.gravy.dataconnectivity;
043:
044: /**
045: * This class implements an object DataSource, which is used for storing
046: * of various parameters of a datasource.
047: */
048: public class DataSource {
049: private String dbType = "", dbUrl = "", dbHost = "", dbName = "",
050: hostName = "", user = "", password = "", port = "",
051: validationTable = null;
052:
053: /**
054: * Returns a type of database.
055: * @return string with a type of database.
056: */
057: public String getDbType() {
058: return dbType;
059: }
060:
061: /**
062: * Returns a database URL.
063: * @return string with a database URL.
064: */
065: public String getDbUrl() {
066: return dbUrl;
067: }
068:
069: /**
070: * Returns a database host.
071: * @return string with a database host.
072: */
073: public String getDbHost() {
074: return dbHost;
075: }
076:
077: /**
078: * Returns a database name.
079: * @return string with a database name.
080: */
081: public String getDbName() {
082: return dbName;
083: }
084:
085: /**
086: * Returns a host name.
087: * @return string with a host name.
088: */
089: public String getHostName() {
090: return hostName;
091: }
092:
093: /**
094: * Returns an user name.
095: * @return string with an user name.
096: */
097: public String getUser() {
098: return user;
099: }
100:
101: /**
102: * Returns a password.
103: * @return string with a password.
104: */
105: public String getPassword() {
106: return password;
107: }
108:
109: /**
110: * Returns a database port number.
111: * @return string with a port number.
112: */
113: public String getPort() {
114: return port;
115: }
116:
117: /**
118: * Returns a database host.
119: * @return string with a database host.
120: */
121: public String getValidationTable() {
122: return validationTable;
123: }
124:
125: /**
126: * Creates an instance of this class.
127: * @param p_dbHost string with a database host
128: * @param p_dbName string with a database name
129: * @param p_user string with an user name
130: * @param p_password string with an user password
131: * @param p_port string with a database port
132: */
133: public DataSource(String p_dbHost, String p_dbName, String p_user,
134: String p_password, String p_port) {
135: this ("", p_dbHost, p_dbName, p_user, p_password, p_port);
136: }
137:
138: /**
139: * Creates an instance of this class.
140: * @param p_dbType string with a database type
141: * @param p_dbHost string with a database host
142: * @param p_dbName string with a database name
143: * @param p_user string with an user name
144: * @param p_password string with an user password
145: * @param p_port string with a database port
146: */
147: public DataSource(String p_dbType, String p_dbHost,
148: String p_dbName, String p_user, String p_password,
149: String p_port) {
150: this (p_dbType, p_dbHost, p_dbName, p_user, p_password, p_port,
151: null);
152: }
153:
154: /**
155: * Creates an instance of this class.
156: * @param p_dbType string with a database type
157: * @param p_dbHost string with a database host
158: * @param p_dbName string with a database name
159: * @param p_user string with an user name
160: * @param p_password string with an user password
161: * @param p_port string with a database port
162: * @param p_validationTable
163: */
164: public DataSource(String p_dbType, String p_dbHost,
165: String p_dbName, String p_user, String p_password,
166: String p_port, String p_validationTable) {
167: setDbType(p_dbType);
168: setDbHost(p_dbHost);
169: setDbName(p_dbName);
170: setUser(p_user);
171: setPassword(p_password);
172: setPort(p_port);
173: setValidationTable(p_validationTable);
174: setDbUrl("");
175: //@todo parse dbUrl
176: }
177:
178: /**
179: * Creates an instance of this class.
180: * @param p_ds an another DataSource object (a prototype of new datasource)
181: */
182: public DataSource(DataSource p_ds) {
183: setDbType(p_ds.getDbType());
184: setDbHost(p_ds.getDbHost());
185: setDbName(p_ds.getDbName());
186: setUser(p_ds.getUser());
187: setPassword(p_ds.getPassword());
188: setPort(p_ds.getPort());
189: setDbUrl(p_ds.getDbUrl());
190: setValidationTable(p_ds.getValidationTable());
191: }
192:
193: /**
194: * Changes a database type for a datasource.
195: * @param dbType string with a database type
196: */
197: public void setDbType(String dbType) {
198: this .dbType = dbType;
199: }
200:
201: /**
202: * Changes a database URL for a datasource.
203: * @param dbUrl string with a database URL
204: */
205: public void setDbUrl(String dbUrl) {
206: this .dbUrl = dbUrl;
207: }
208:
209: /**
210: * Changes a database host for a datasource.
211: * @param dbHost string with a database host
212: */
213: public void setDbHost(String dbHost) {
214: this .dbHost = dbHost;
215: }
216:
217: /**
218: * Changes a database name for a datasource.
219: * @param dbName string with a database name
220: */
221: public void setDbName(String dbName) {
222: this .dbName = dbName;
223: }
224:
225: /**
226: * Changes a host name for a datasource.
227: * @param hostName string with a host name
228: */
229: public void setHostName(String hostName) {
230: this .hostName = hostName;
231: }
232:
233: /**
234: * Changes an user name for a datasource.
235: * @param user an user name
236: */
237: public void setUser(String user) {
238: this .user = user;
239: }
240:
241: /**
242: * Changes a password for a datasource.
243: * @param password an user password
244: */
245: public void setPassword(String password) {
246: this .password = password;
247: }
248:
249: /**
250: * Changes a database port number for a datasource.
251: * @param port a database port number
252: */
253: public void setPort(String port) {
254: this .port = port;
255: }
256:
257: public void setValidationTable(String validationTable) {
258: this.validationTable = validationTable;
259: }
260: }
|