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.sql.framework.model;
042:
043: import java.util.List;
044:
045: import org.w3c.dom.Element;
046:
047: import com.sun.sql.framework.exception.BaseException;
048:
049: /**
050: * Defines methods for obtaining metadata of an SQL operator.
051: *
052: * @author Jonathan Giron
053: * @version $Revision$
054: */
055: public interface SQLOperatorDefinition extends Cloneable {
056:
057: public static final String ATTR_AGGREGATE_FUNCTION = "aggregate_function";
058:
059: public static final String ATTR_SHOWPARENTHESIS = "showparenthesis";
060:
061: /**
062: * get a list of argument to use while calculating precision and scale
063: */
064: public List getArg2Use();
065:
066: /**
067: * Gets the number of input arguments defined in the script. If the operator script
068: * defines an operator with variable number of arguments then we allow a maximum of
069: * 100 input arguments.
070: *
071: * @return maximum number of arguments this operator can support.
072: */
073: public int getArgCount();
074:
075: /**
076: * Indicates if this operator can take a variable number of input arguments.
077: *
078: * @return flag indicating weather this operator takes variable number of input
079: * arguments.
080: */
081: public int getArgCountType();
082:
083: /**
084: * Gets index of argument associated with given name, if any.
085: *
086: * @param arg Argument name
087: * @return Argument index if successful, -1 if failed.
088: */
089: public int getArgIndex(String arg);
090:
091: /**
092: * Gets the argument name, if any, associated with the given index.
093: *
094: * @param i index of argument.
095: * @return JDBC type if successful, JDBCSQL_TYPE_UNDEFINED if failed.
096: * @see SQLConstants#JDBCSQL_TYPE_UNDEFINED
097: */
098: public int getArgJdbcSQLType(int i);
099:
100: /**
101: * Gets the JDBC sql type associated with the given argument name.
102: *
103: * @param argName name of argument
104: * @return JDBC type if successful, JDBCSQL_TYPE_UNDEFINED if failed.
105: * @see SQLConstants#JDBCSQL_TYPE_UNDEFINED
106: */
107: public int getArgJdbcSQLType(String argName);
108:
109: /**
110: * Get List of current arguments.
111: *
112: * @return Argument list.
113: */
114: public List getArgList();
115:
116: /**
117: * Set argument list
118: *
119: * @param args List
120: */
121: public void setArgList(List<SQLOperatorArg> args);
122:
123: /**
124: * Gets the SQL type of the argument, if any, associated with the given index.
125: *
126: * @param i index of argument
127: * @return SQL type of argument indexed by i, null if no argument exists at i.
128: */
129: public String getArgType(int i);
130:
131: /**
132: * @see SQLObject#getAttributeObject
133: */
134: public Object getAttributeValue(String attrName);
135:
136: /**
137: * get the database specfic name of the operator
138: */
139: public String getDbSpecficName();
140:
141: /**
142: * get the gui representation of operator
143: */
144: public String getGuiName();
145:
146: /**
147: * Gets Operator Arg for the given index
148: *
149: * @param index for OperatorArg
150: * @return SQLOperatorArg
151: */
152: public SQLOperatorArg getOperatorArg(int index);
153:
154: /**
155: * get the category type of the operator (numeric of string)
156: *
157: * @return operator category type
158: */
159: public String getOperatorCategoryType();
160:
161: /**
162: * Gets the canonical name of this operator.
163: *
164: * @return canonical name of operator
165: */
166: public String getOperatorName();
167:
168: /**
169: * Gets JDBC SQL type of this operator's output
170: *
171: * @return JDBC type if successful, -65535 if failed.
172: */
173: public int getOutputJdbcSQLType();
174:
175: /**
176: * sets the jdbc type of this operators return type
177: * @param int jdbcType sql constant for the type
178: */
179: public void setOutputJdbcSQLType(int jdbcType);
180:
181: /**
182: * This method is another convenience method to compute
183: * the sql constant for the given string and set the jdbc type
184: * sets the jdbc type of this operators return type
185: * @param String jdbcType
186: */
187: public void setOutputJdbcSQLType(String jdbcType);
188:
189: /**
190: * Gets the range based on argname
191: *
192: * @param argName for which range is returned
193: * @return String for range
194: */
195: public String getRange(String argName);
196:
197: /**
198: * Gets the script associated with this operator.
199: *
200: * @return SQL text representation of this operator, if any.
201: */
202: public String getScript();
203:
204: /**
205: * Gets base name of argument, if any, used in generating arguments for operators that
206: * can accept multiple inputs of the same type ("var" operators, e.g., "varconcat",
207: * "varadd").
208: *
209: * @return name of var argument
210: */
211: public String getVarOperatorArgName();
212:
213: /**
214: * Reads this operator's script and configuration information from the given DOM
215: * element.
216: *
217: * @param element DOM element containing operator configuration information
218: */
219: public void parseXML(Element element) throws BaseException;
220:
221: /**
222: * Clone itself. Operator Definitions are immutable, except UserFunction definition.
223: */
224: /**
225: * @param operatorArgs List of SQLOperatorArg
226: * @return
227: */
228: public Object clone(List operatorArgs);
229: }
|