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.sql.framework.model.impl;
043:
044: import java.util.Collection;
045: import java.util.Iterator;
046: import java.util.List;
047: import java.util.Map;
048:
049: import org.netbeans.modules.sql.framework.model.GUIInfo;
050: import org.netbeans.modules.sql.framework.model.SQLInputObject;
051: import org.netbeans.modules.sql.framework.model.SQLLiteral;
052: import org.netbeans.modules.sql.framework.model.SQLObject;
053: import org.netbeans.modules.sql.framework.model.SQLOperatorArg;
054: import org.netbeans.modules.sql.framework.model.SQLOperatorDefinition;
055: import org.netbeans.modules.sql.framework.model.SQLPredicate;
056: import org.netbeans.modules.sql.framework.model.VisibleSQLPredicate;
057: import org.netbeans.modules.sql.framework.model.visitors.SQLVisitor;
058: import org.netbeans.modules.sql.framework.ui.graph.IOperatorXmlInfo;
059: import org.w3c.dom.Element;
060:
061: import com.sun.sql.framework.exception.BaseException;
062: import com.sun.sql.framework.utils.Attribute;
063:
064: /**
065: * @author Ritesh Adval
066: */
067: public class VisibleMatchesPredicateImpl implements VisibleSQLPredicate {
068: private VisibleSQLPredicate delegate = null;
069:
070: public VisibleMatchesPredicateImpl() {
071: delegate = new VisibleSQLPredicateImpl();
072: }
073:
074: public VisibleMatchesPredicateImpl(VisibleMatchesPredicateImpl src)
075: throws BaseException {
076: this ();
077: if (src == null) {
078: throw new IllegalArgumentException(
079: "can not create VisibleSQLPredicate using copy constructor, src is null");
080: }
081: try {
082: delegate = (VisibleSQLPredicate) ((VisibleSQLPredicateImpl) src.delegate)
083: .clone();
084: } catch (CloneNotSupportedException ex) {
085: throw new BaseException(ex);
086: }
087: }
088:
089: public void addInput(String argName, SQLObject newInput)
090: throws BaseException {
091: delegate.addInput(argName, newInput);
092: }
093:
094: public Object clone() throws CloneNotSupportedException {
095: try {
096: VisibleMatchesPredicateImpl vmPredicate = new VisibleMatchesPredicateImpl(
097: this );
098: return vmPredicate;
099: } catch (BaseException ex) {
100: throw new CloneNotSupportedException(
101: "can not create clone of " + this .getOperatorType());
102: }
103: }
104:
105: public Object cloneSQLObject() throws CloneNotSupportedException {
106: return this .clone();
107: }
108:
109: public Object getArgumentValue(String argName) throws BaseException {
110: return delegate.getArgumentValue(argName);
111: }
112:
113: public Attribute getAttribute(String attrName) {
114: return delegate.getAttribute(attrName);
115: }
116:
117: public Collection getAttributeNames() {
118: return delegate.getAttributeNames();
119: }
120:
121: public Object getAttributeObject(String attrName) {
122: return delegate.getAttributeObject(attrName);
123: }
124:
125: public List getChildSQLObjects() {
126: return delegate.getChildSQLObjects();
127: }
128:
129: public String getCustomOperatorName() {
130: return delegate.getCustomOperatorName();
131: }
132:
133: public String getDisplayName() {
134: return delegate.getDisplayName();
135: }
136:
137: public String getFooter() {
138: return delegate.getFooter();
139: }
140:
141: public GUIInfo getGUIInfo() {
142: return delegate.getGUIInfo();
143: }
144:
145: public String getHeader() {
146: return delegate.getHeader();
147: }
148:
149: public String getId() {
150: return delegate.getId();
151: }
152:
153: public SQLInputObject getInput(String argName) {
154: return delegate.getInput(argName);
155: }
156:
157: public Map getInputObjectMap() {
158: return delegate.getInputObjectMap();
159: }
160:
161: public int getJdbcType() {
162: return delegate.getJdbcType();
163: }
164:
165: public int getObjectType() {
166: return delegate.getObjectType();
167: }
168:
169: public SQLOperatorDefinition getOperatorDefinition() {
170: return delegate.getOperatorDefinition();
171: }
172:
173: public String getOperatorType() {
174: return delegate.getOperatorType();
175: }
176:
177: public IOperatorXmlInfo getOperatorXmlInfo() {
178: return delegate.getOperatorXmlInfo();
179: }
180:
181: public SQLObject getOutput(String argName) throws BaseException {
182: return this ;
183: }
184:
185: public Object getParentObject() {
186: return delegate.getParentObject();
187: }
188:
189: public SQLPredicate getRoot() {
190: return delegate.getRoot();
191: }
192:
193: public List getSourceColumnsUsed() {
194: return delegate.getSourceColumnsUsed();
195: }
196:
197: public SQLObject getSQLObject(String argName) {
198: return delegate.getSQLObject(argName);
199: }
200:
201: public Map getSQLObjectMap() {
202: return delegate.getSQLObjectMap();
203: }
204:
205: public List getTargetColumnsUsed() {
206: return delegate.getTargetColumnsUsed();
207: }
208:
209: public boolean hasSourceColumn() {
210: return delegate.hasSourceColumn();
211: }
212:
213: public boolean hasTargetColumn() {
214: return delegate.hasTargetColumn();
215: }
216:
217: public boolean isCustomOperator() {
218: return delegate.isCustomOperator();
219: }
220:
221: public int isInputCompatible(String argName, SQLObject input) {
222: return delegate.isInputCompatible(argName, input);
223: }
224:
225: public boolean isInputStatic(String inputName) {
226: return delegate.isInputStatic(inputName);
227: }
228:
229: public boolean isInputValid(String argName, SQLObject input) {
230: return delegate.isInputValid(argName, input);
231: }
232:
233: public boolean isShowParenthesis() {
234: return delegate.isShowParenthesis();
235: }
236:
237: public void parseXML(Element element) throws BaseException {
238: delegate.parseXML(element);
239: }
240:
241: public SQLObject removeInputByArgName(String argName,
242: SQLObject sqlObj) throws BaseException {
243: return delegate.removeInputByArgName(argName, sqlObj);
244: }
245:
246: public void reset() {
247: delegate.reset();
248: }
249:
250: public void secondPassParse(Element element) throws BaseException {
251: delegate.secondPassParse(element);
252: }
253:
254: public void setArgument(String argName, Object val)
255: throws BaseException {
256: if (val instanceof VisibleSQLLiteralImpl) {
257: VisibleSQLLiteralImpl visLiteral = (VisibleSQLLiteralImpl) val;
258: SQLLiteral literal = new SQLLiteralImpl(visLiteral);
259: delegate.setArgument(argName, literal);
260: } else {
261: delegate.setArgument(argName, val);
262: }
263: }
264:
265: public void setArguments(List args) throws BaseException {
266: SQLOperatorDefinition operatorDefinition = delegate
267: .getOperatorDefinition();
268: if (operatorDefinition == null) {
269: throw new BaseException("Operator Definition is null.");
270: }
271:
272: if (args != null) {
273: // now add inputs from the arg list
274: Iterator it = args.iterator();
275: int argIdx = 0;
276: while (it.hasNext()) {
277: SQLObject argValue = (SQLObject) it.next();
278: SQLOperatorArg operatorArg = operatorDefinition
279: .getOperatorArg(argIdx);
280: String argName = operatorArg.getArgName();
281: setArgument(argName, argValue);
282: argIdx++;
283: }
284: }
285: }
286:
287: public void setAttribute(String attrName, Object val) {
288: delegate.setAttribute(attrName, val);
289: }
290:
291: public void setCustomOperator(boolean userFx) {
292: delegate.setCustomOperator(userFx);
293: }
294:
295: public void setCustomOperatorName(String userFxName) {
296: delegate.setCustomOperatorName(userFxName);
297: }
298:
299: public void setDbSpecificOperator(String dbName)
300: throws BaseException {
301: delegate.setDbSpecificOperator(dbName);
302: }
303:
304: public void setDisplayName(String newName) {
305: delegate.setDisplayName(newName);
306: }
307:
308: public void setId(String newId) throws BaseException {
309: delegate.setId(newId);
310: }
311:
312: public void setJdbcType(int newType) {
313: delegate.setJdbcType(newType);
314: }
315:
316: public void setOperatorType(String newOperator)
317: throws BaseException {
318: delegate.setOperatorType(newOperator);
319: }
320:
321: public void setOperatorXmlInfo(IOperatorXmlInfo opInfo)
322: throws BaseException {
323: delegate.setOperatorXmlInfo(opInfo);
324: }
325:
326: public void setParentObject(Object newParent) throws BaseException {
327: delegate.setParentObject(newParent);
328: }
329:
330: public void setRoot(SQLPredicate pred) {
331: delegate.setRoot(pred);
332: }
333:
334: public void setShowParenthesis(boolean show) {
335: delegate.setShowParenthesis(show);
336: }
337:
338: public String toString() {
339: return delegate.toString();
340: }
341:
342: public String toXMLString(String prefix) throws BaseException {
343: return delegate.toXMLString(prefix);
344: }
345:
346: public void visit(SQLVisitor visitor) {
347: visitor.visit(this);
348: }
349: }
|