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: package org.netbeans.modules.visualweb.dataconnectivity.sql;
042:
043: /**
044: * Class used to present a datasource available for export
045: * can be annotated with whether or not should be exported
046: * and whether or not username and/or password should be exported
047: *
048: * @author John Kline
049: */
050: public class DataSourceExport {
051:
052: private boolean exportable;
053: private boolean usernameExportable;
054: private boolean passwordExportable; // assume false if usernameExportable is false
055: private String name;
056: private String driverClassName;
057: private String url;
058: private String username;
059: private String password;
060: private String validationQuery;
061:
062: private String alias;
063:
064: public DataSourceExport(String name, String driverClassName,
065: String url, String username, String password,
066: String validationQuery) {
067:
068: exportable = true;
069: usernameExportable = true;
070: passwordExportable = true;
071: this .name = name;
072: this .driverClassName = driverClassName;
073: this .url = url;
074: this .username = username;
075: this .password = password;
076: this .validationQuery = validationQuery;
077: this .alias = null;
078: }
079:
080: public DataSourceExport(String name, String alias) {
081: exportable = true;
082: this .name = name;
083: this .alias = alias;
084: }
085:
086: public boolean isExportable() {
087: return exportable;
088: }
089:
090: public void setExportable(boolean exportable) {
091: this .exportable = exportable;
092: }
093:
094: public boolean isUsernameExportable() {
095: return usernameExportable;
096: }
097:
098: public void setUsernameExportable(boolean usernameExportable) {
099: this .usernameExportable = usernameExportable;
100: }
101:
102: public boolean isPasswordExportable() {
103: return passwordExportable;
104: }
105:
106: public void setPasswordExportable(boolean passwordExportable) {
107: this .passwordExportable = passwordExportable;
108: }
109:
110: public String getName() {
111: return name;
112: }
113:
114: public String getDisplayName() {
115: return getName().replaceFirst("java:comp/env/jdbc/", ""); // NOI18N
116: }
117:
118: public void setName(String name) {
119: this .name = name;
120: }
121:
122: public String getDriverClassName() {
123: return driverClassName;
124: }
125:
126: public void setDriverClassName(String driverClassName) {
127: this .driverClassName = driverClassName;
128: }
129:
130: public String getUrl() {
131: return url;
132: }
133:
134: public void setUrl(String url) {
135: this .url = url;
136: }
137:
138: public String getUsername() {
139: return username;
140: }
141:
142: public void setUsername(String username) {
143: this .username = username;
144: }
145:
146: public String getPassword() {
147: return password;
148: }
149:
150: public void setPassword(String password) {
151: this .password = password;
152: }
153:
154: public String getValidationQuery() {
155: return validationQuery;
156: }
157:
158: public void setValidationQuery(String validationQuery) {
159: this .validationQuery = validationQuery;
160: }
161:
162: // We only store the ValidationQuery as "select * from <table>"
163: // Extract the <table> here.
164: public String getValidationTable() {
165: // see if it start's with SELECT_PHRASE, otherwise try a hack
166: String validationTable = DesignTimeDataSource
167: .parseForValidationTable(getValidationQuery());
168: return (validationTable == null ? "" : validationTable); // NOI18N
169: }
170:
171: public void setValidationTable(String table) {
172: // setValidationQuery( DesignTimeDataSource.composeValidationQuery(table) ) ;
173: }
174:
175: public void setAlias(String alias) {
176: this .alias = alias;
177: }
178:
179: public String getAlias() {
180: return this .alias;
181: }
182:
183: public boolean isAlias() {
184: return (this.alias != null);
185: }
186: }
|