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: * Portions Copyrighted 2007 Sun Microsystems, Inc.
027: */
028: package org.netbeans.modules.ruby.elements;
029:
030: import org.netbeans.modules.gsf.api.ElementKind;
031: import org.netbeans.modules.ruby.RubyIndex;
032:
033: /**
034: *
035: * @author Tor Norbye
036: */
037: public class IndexedField extends IndexedElement {
038: private boolean smart;
039: private String name;
040: private boolean inherited;
041:
042: private IndexedField(String name, RubyIndex index, String fileUrl,
043: String fqn, String clz, String require, String attributes,
044: int flags) {
045: super (index, fileUrl, fqn, clz, require, attributes, flags);
046: this .name = name;
047: }
048:
049: public static IndexedField create(RubyIndex index, String name,
050: String fqn, String clz, String fileUrl, String require,
051: String attributes, int flags) {
052: IndexedField m = new IndexedField(name, index, fileUrl, fqn,
053: clz, require, attributes, flags);
054:
055: return m;
056: }
057:
058: public ElementKind getKind() {
059: return ElementKind.FIELD;
060: }
061:
062: @Override
063: public String getSignature() {
064: return fqn + "#@" + (isStatic() ? "@" : "") + name;
065: }
066:
067: public String getName() {
068: return name;
069: }
070:
071: public boolean isSmart() {
072: return smart;
073: }
074:
075: public void setSmart(boolean smart) {
076: this .smart = smart;
077: }
078:
079: @Override
080: public boolean equals(Object obj) {
081: if (obj == null) {
082: return false;
083: }
084: if (getClass() != obj.getClass()) {
085: return false;
086: }
087: final IndexedField other = (IndexedField) obj;
088: if (this .name != other.name
089: && (this .name == null || !this .name.equals(other.name))) {
090: return false;
091: }
092: if (this .fqn != other.fqn
093: && (this .fqn == null || !this .fqn.equals(other.fqn))) {
094: return false;
095: }
096: if (this .flags != other.flags) {
097: return false;
098: }
099: return true;
100: }
101:
102: @Override
103: public int hashCode() {
104: int hash = 7;
105: hash = 43 * hash
106: + (this .name != null ? this .name.hashCode() : 0);
107: hash = 43 * hash + (this .fqn != null ? this .fqn.hashCode() : 0);
108: hash = 53 * hash + flags;
109: return hash;
110: }
111:
112: public boolean isInherited() {
113: return inherited;
114: }
115:
116: public void setInherited(boolean inherited) {
117: this .inherited = inherited;
118: }
119:
120: public static String decodeFlags(int flags) {
121: return IndexedElement.decodeFlags(flags);
122: }
123: }
|