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: /**
044: * Holds name and JDBCtype of an argument in SQLOperatorDefinition.
045: *
046: * @author Amrish K. Lal
047: * @version $Revision$
048: */
049: public final class SQLOperatorArg {
050:
051: /* Argument name */
052: private String argName = null;
053:
054: /* Argument type */
055: private int jdbcType = SQLConstants.JDBCSQL_TYPE_UNDEFINED;
056:
057: private String range;
058:
059: /**
060: * Constructs a new instance of SQLOperatorArg with the given name and JDBC typecode.
061: *
062: * @param newName argument name
063: * @param newType JDBC sql type.
064: */
065: public SQLOperatorArg(String newName, int newType) {
066: argName = newName;
067: jdbcType = newType;
068: }
069:
070: /**
071: * Overrides default implementation to account for member variables.
072: *
073: * @param refObj to be checked for equality
074: * @return true if refObj equals this; false otherwise
075: */
076: public boolean equals(Object refObj) {
077: // First check for reflexivity.
078: if (this == refObj) {
079: return true;
080: }
081:
082: // Next check for class type..also checks for null refObj
083: if (!(refObj instanceof SQLOperatorArg)) {
084: return (false);
085: }
086:
087: SQLOperatorArg arg = (SQLOperatorArg) refObj;
088: if (this .argName != null) {
089: if (!this .argName.equals(arg.getArgName())) {
090: return false;
091: }
092: } else if (arg.getArgName() != null) {
093: return false;
094: }
095:
096: return this .jdbcType == arg.getJdbcType();
097: }
098:
099: /**
100: * Gets name of this argument.
101: *
102: * @return argument name
103: */
104: public String getArgName() {
105: return (this .argName);
106: }
107:
108: /**
109: * Gets JDBC typecode of this argument.
110: *
111: * @return JDBC typecode
112: */
113: public int getJdbcType() {
114: return (this .jdbcType);
115: }
116:
117: /**
118: * Setter for Condition to be evaluated for operators
119: *
120: * @return condition to be evaluated
121: */
122: public String getRange() {
123: return this .range;
124: }
125:
126: /**
127: * @see java.lang.Object#hashCode
128: */
129: public int hashCode() {
130: int myHash = (argName != null) ? argName.hashCode() : 0;
131: myHash += jdbcType;
132:
133: return myHash;
134: }
135:
136: /**
137: * Setter for Condition to be evaluated for operators
138: *
139: * @param theRange to be evaluated
140: */
141: public void setRange(String theRange) {
142: this.range = theRange;
143: }
144:
145: }
|