001: package net.sourceforge.squirrel_sql.plugins.sqlscript.prefs;
002:
003: /*
004: * Copyright (C) 2006 Rob Manning
005: * manningr@users.sourceforge.net
006: *
007: * This library is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU Lesser General Public
009: * License as published by the Free Software Foundation; either
010: * version 2.1 of the License, or (at your option) any later version.
011: *
012: * This library is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this library; if not, write to the Free Software
019: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020: */
021: import java.io.Serializable;
022:
023: /**
024: * A bean class to store preferences for the SQLScript plugin.
025: */
026: public class SQLScriptPreferenceBean implements Cloneable, Serializable {
027: static final String UNSUPPORTED = "Unsupported";
028:
029: /** Client Name. */
030: private String _clientName;
031:
032: /** Client version. */
033: private String _clientVersion;
034:
035: /** whether or not to qualify table names with the schema when generating
036: * scripts*/
037: private boolean qualifyTableNames = true;
038:
039: public static final int NO_ACTION = 0;
040:
041: public static final int CASCADE_DELETE = 1;
042:
043: public static final int SET_DEFAULT = 2;
044:
045: public static final int SET_NULL = 3;
046:
047: private int deleteAction = NO_ACTION;
048:
049: private int updateAction = NO_ACTION;
050:
051: /**
052: * whether or not to override the delete referential action for FK defs.
053: */
054: private boolean deleteRefAction = false;
055:
056: /**
057: * whether or not to override the update referential action for FK defs.
058: */
059: private boolean updateRefAction = false;
060:
061: public SQLScriptPreferenceBean() {
062: super ();
063: }
064:
065: /**
066: * Return a copy of this object.
067: */
068: public Object clone() {
069: try {
070: return super .clone();
071: } catch (CloneNotSupportedException ex) {
072: throw new InternalError(ex.getMessage()); // Impossible.
073: }
074: }
075:
076: /**
077: * Retrieve the client to use. This is only
078: * used if <TT>useAnonymousClient</TT> is false.
079: *
080: * @return Client name.
081: */
082: public String getClientName() {
083: return _clientName;
084: }
085:
086: /**
087: * Set the client name.
088: *
089: * @param value Client name
090: */
091: public void setClientName(String value) {
092: _clientName = value;
093: }
094:
095: /**
096: * Retrieve the client version to use. This is only
097: * used if <TT>useAnonymousLogon</TT> is false.
098: *
099: * @return Client version.
100: */
101: public String getClientVersion() {
102: return _clientVersion;
103: }
104:
105: /**
106: * Set the client version.
107: *
108: * @param value Client version
109: */
110: public void setClientVersion(String value) {
111: _clientVersion = value;
112: }
113:
114: /**
115: * Sets whether or not to qualify table names with the schema when
116: * generating scripts
117: *
118: * @param qualifyTableNames a boolean value
119: */
120: public void setQualifyTableNames(boolean qualifyTableNames) {
121: this .qualifyTableNames = qualifyTableNames;
122: }
123:
124: /**
125: * Returns a boolean value indicating whether or not to qualify table names
126: * with the schema when generating scripts
127: *
128: * @return Returns the value of qualifyTableNames.
129: */
130: public boolean isQualifyTableNames() {
131: return qualifyTableNames;
132: }
133:
134: public void setDeleteRefAction(boolean deleteRefAction) {
135: this .deleteRefAction = deleteRefAction;
136: }
137:
138: public boolean isDeleteRefAction() {
139: return deleteRefAction;
140: }
141:
142: public void setDeleteAction(int action) {
143: this .deleteAction = action;
144: }
145:
146: public int getDeleteAction() {
147: return deleteAction;
148: }
149:
150: public void setUpdateAction(int updateAction) {
151: this .updateAction = updateAction;
152: }
153:
154: public int getUpdateAction() {
155: return updateAction;
156: }
157:
158: public void setUpdateRefAction(boolean updateRefAction) {
159: this .updateRefAction = updateRefAction;
160: }
161:
162: public boolean isUpdateRefAction() {
163: return updateRefAction;
164: }
165:
166: public String getRefActionByType(int type) {
167: switch (type) {
168: case NO_ACTION:
169: return "NO ACTION";
170: case CASCADE_DELETE:
171: return "CASCADE";
172: case SET_DEFAULT:
173: return "SET DEFAULT";
174: case SET_NULL:
175: return "SET NULL";
176: default:
177: return "NO ACTION";
178: }
179: }
180:
181: }
|