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: * @version $Revision$
066: */
067: public class SQLNormalizeOperatorImpl implements SQLGenericOperator {
068:
069: public static final String ARG_LOCALE = "locale";
070: public static final String ARG_PART = "part";
071: public static final String ARG_PERSONNAME = "PersonName";
072: public static final String ARG_STR = "str";
073:
074: private SQLGenericOperator delegate = null;
075:
076: public SQLNormalizeOperatorImpl() {
077: delegate = new SQLGenericOperatorImpl();
078: }
079:
080: public SQLNormalizeOperatorImpl(SQLNormalizeOperatorImpl src)
081: throws CloneNotSupportedException {
082: this ();
083: if (src == null) {
084: throw new IllegalArgumentException(
085: "can not create VisibleSQLPredicate using copy constructor, src is null");
086: }
087: delegate = (SQLGenericOperator) src.delegate.cloneSQLObject();
088: }
089:
090: public void addInput(String argName, SQLObject newInput)
091: throws BaseException {
092: delegate.addInput(argName, newInput);
093: }
094:
095: public Object clone() throws CloneNotSupportedException {
096: return new SQLNormalizeOperatorImpl(this );
097: }
098:
099: public Object cloneSQLObject() throws CloneNotSupportedException {
100: return this .clone();
101: }
102:
103: public Object getArgumentValue(String argName) throws BaseException {
104: return delegate.getArgumentValue(argName);
105: }
106:
107: public Attribute getAttribute(String attrName) {
108: return delegate.getAttribute(attrName);
109: }
110:
111: public Collection getAttributeNames() {
112: return delegate.getAttributeNames();
113: }
114:
115: public Object getAttributeObject(String attrName) {
116: return delegate.getAttributeObject(attrName);
117: }
118:
119: public List getChildSQLObjects() {
120: return delegate.getChildSQLObjects();
121: }
122:
123: public String getCustomOperatorName() {
124: return delegate.getCustomOperatorName();
125: }
126:
127: public String getDisplayName() {
128: return delegate.getDisplayName();
129: }
130:
131: public String getFooter() {
132: return delegate.getFooter();
133: }
134:
135: public GUIInfo getGUIInfo() {
136: return delegate.getGUIInfo();
137: }
138:
139: public String getHeader() {
140: return delegate.getHeader();
141: }
142:
143: public String getId() {
144: return delegate.getId();
145: }
146:
147: public SQLInputObject getInput(String argName) {
148: return delegate.getInput(argName);
149: }
150:
151: public Map getInputObjectMap() {
152: return delegate.getInputObjectMap();
153: }
154:
155: public int getJdbcType() {
156: return delegate.getJdbcType();
157: }
158:
159: public int getObjectType() {
160: return delegate.getObjectType();
161: }
162:
163: public SQLOperatorDefinition getOperatorDefinition() {
164: return delegate.getOperatorDefinition();
165: }
166:
167: public String getOperatorType() {
168: return delegate.getOperatorType();
169: }
170:
171: public IOperatorXmlInfo getOperatorXmlInfo() {
172: return delegate.getOperatorXmlInfo();
173: }
174:
175: public SQLObject getOutput(String argName) throws BaseException {
176: return this ;
177: }
178:
179: public Object getParentObject() {
180: return delegate.getParentObject();
181: }
182:
183: public List getSourceColumnsUsed() {
184: return delegate.getSourceColumnsUsed();
185: }
186:
187: public SQLObject getSQLObject(String argName) {
188: return delegate.getSQLObject(argName);
189: }
190:
191: public Map getSQLObjectMap() {
192: return delegate.getSQLObjectMap();
193: }
194:
195: public List getTargetColumnsUsed() {
196: return delegate.getTargetColumnsUsed();
197: }
198:
199: public boolean hasSourceColumn() {
200: return delegate.hasSourceColumn();
201: }
202:
203: public boolean hasTargetColumn() {
204: return delegate.hasTargetColumn();
205: }
206:
207: public boolean hasVariableArgs() {
208: return delegate.hasVariableArgs();
209: }
210:
211: public boolean isAggregateFunction() {
212: return delegate.isAggregateFunction();
213: }
214:
215: public int isCastable(String argName, SQLObject input) {
216: return delegate.isCastable(argName, input);
217: }
218:
219: public boolean isCustomOperator() {
220: return delegate.isCustomOperator();
221: }
222:
223: public int isInputCompatible(String argName, SQLObject input) {
224: return delegate.isInputCompatible(argName, input);
225: }
226:
227: public boolean isInputStatic(String argName) {
228: return delegate.isInputStatic(argName);
229: }
230:
231: public boolean isInputValid(String argName, SQLObject input) {
232: return delegate.isInputValid(argName, input);
233: }
234:
235: public boolean isShowParenthesis() {
236: return delegate.isShowParenthesis();
237: }
238:
239: public void parseXML(Element element) throws BaseException {
240: delegate.parseXML(element);
241: }
242:
243: public SQLObject removeInputByArgName(String argName,
244: SQLObject sqlObj) throws BaseException {
245: return delegate.removeInputByArgName(argName, sqlObj);
246: }
247:
248: public void reset() {
249: delegate.reset();
250: }
251:
252: public void secondPassParse(Element element) throws BaseException {
253: delegate.secondPassParse(element);
254: }
255:
256: public void setArgument(String argName, Object val)
257: throws BaseException {
258: if (ARG_PART.equals(argName) || ARG_LOCALE.equals(argName)) {
259: if (val instanceof VisibleSQLLiteralImpl) {
260: VisibleSQLLiteralImpl visLiteral = (VisibleSQLLiteralImpl) val;
261: SQLLiteral literal = new SQLLiteralImpl(visLiteral);
262: delegate.setArgument(argName, literal);
263: } else {
264: delegate.setArgument(argName, val);
265: }
266: } else {
267: delegate.setArgument(argName, val);
268: }
269: }
270:
271: public void setArguments(List opArgs) throws BaseException {
272: SQLOperatorDefinition operatorDefinition = delegate
273: .getOperatorDefinition();
274: if (operatorDefinition == null) {
275: throw new BaseException("Operator Definition is null.");
276: }
277:
278: if (opArgs != null) {
279: //now add inputs from the arg list
280: Iterator it = opArgs.iterator();
281: int i = 0;
282: while (it.hasNext()) {
283: SQLObject argValue = (SQLObject) it.next();
284: if (i == 0 && argValue instanceof SQLLiteral) {
285: SQLLiteral literal = (SQLLiteral) argValue;
286: String val = literal.getValue();
287: if (ARG_PERSONNAME.equals(val)) {
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: }
|