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