EclipseJDT ASTViewer Source Viewer

Home|eclipse_jdt_astviewer/src/org/eclipse/jdt/astview/views/BindingProperty.java
1/*******************************************************************************
2 * Copyright (c) 2000, 2017 IBM Corporation and others.
3 *
4 * This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License 2.0
6 * which accompanies this distribution, and is available at
7 * https://www.eclipse.org/legal/epl-2.0/
8 *
9 * SPDX-License-Identifier: EPL-2.0
10 *
11 * Contributors:
12 *     IBM Corporation - initial API and implementation
13 *******************************************************************************/
14package org.eclipse.jdt.astview.views;
15
16
17import java.util.Objects;
18
19import org.eclipse.swt.graphics.Image;
20
21import org.eclipse.jdt.core.dom.IBinding;
22
23/**
24 *
25 */
26public class BindingProperty extends ASTAttribute {
27
28    private final String fName;
29    private final Binding fParent;
30    private final ASTAttribute[] fValues;
31    private final boolean fIsRelevant;
32
33    public BindingProperty(Binding parentString nameObject valueboolean isRelevant) {
34        fParentparent;
35        if (value instanceof String) {
36            if (((Stringvalue).length() == 0) {
37                fNamename + ": (empty string)"//$NON-NLS-1$
38            } else {
39                fNamename + ": " + Binding.getEscapedStringLiteral((Stringvalue); //$NON-NLS-1$
40            }
41        } else if (value instanceof Character) {
42            fNamename + ": " + Binding.getEscapedCharLiteral(((Charactervalue)); //$NON-NLS-1$
43        } else {
44            fNamename + ": " + String.valueOf(value); //$NON-NLS-1$
45        }
46        fValuesnull;
47        fIsRelevantisRelevant;
48    }
49
50    public BindingProperty(Binding parentString nameboolean valueboolean isRelevant) {
51        fParentparent;
52        fNamename + ": " + String.valueOf(value); //$NON-NLS-1$
53        fValuesnull;
54        fIsRelevantisRelevant;
55    }
56
57    public BindingProperty(Binding parentString nameint valueboolean isRelevant) {
58        fParentparent;
59        fNamename + ": " + String.valueOf(value); //$NON-NLS-1$
60        fValuesnull;
61        fIsRelevantisRelevant;
62    }
63
64    public BindingProperty(Binding parentString nameIBinding[] bindingsboolean isRelevant) {
65        fParentparent;
66        if (bindings == null) {
67            fNamename + " (null)"//$NON-NLS-1$
68            fValuesnull;
69        } else {
70            fValuescreateBindings(bindingsisRelevant);
71            fNamename + " (" + fValues.length + ')'//$NON-NLS-1$
72        }
73        fIsRelevantisRelevant;
74    }
75
76    public BindingProperty(Binding parentString nameASTAttribute[] childrenboolean isRelevant) {
77        fParentparent;
78        if (children == null) {
79            children= new ASTAttribute[0];
80        }
81        fValueschildren;
82        fNamename + " (" + fValues.length + ')'//$NON-NLS-1$
83        fIsRelevantisRelevant;
84    }
85
86
87    @Deprecated
88    public BindingProperty(Binding parentStringBuffer labelboolean isRelevant) {
89        fParentparent;
90        fNamelabel.toString();
91        fValuesnull;
92        fIsRelevantisRelevant;
93    }
94
95    public BindingProperty(Binding parentStringBuilder labelboolean isRelevant) {
96        fParentparent;
97        fNamelabel.toString();
98        fValuesnull;
99        fIsRelevantisRelevant;
100    }
101
102    private Binding[] createBindings(IBinding[] bindingsboolean isRelevant) {
103        Binding[] res= new Binding[bindings.length];
104        for (int i0i < res.lengthi++) {
105            res[i]= new Binding(this, String.valueOf(i), bindings[i], isRelevant);
106        }
107        return res;
108    }
109
110    @Override
111    public Object getParent() {
112        return fParent;
113    }
114
115    @Override
116    public Object[] getChildren() {
117        if (fValues != null) {
118            return fValues;
119        }
120        return EMPTY;
121    }
122
123    @Override
124    public String getLabel() {
125        return fName;
126    }
127
128    @Override
129    public Image getImage() {
130        return null;
131    }
132
133    @Override
134    public String toString() {
135        return getLabel();
136    }
137
138    public boolean isRelevant() {
139        return fIsRelevant;
140    }
141
142    /*
143     * @see java.lang.Object#equals(java.lang.Object)
144     */
145    @Override
146    public boolean equals(Object obj) {
147        if (this == obj)
148            return true;
149        if (obj == null || !obj.getClass().equals(getClass())) {
150            return false;
151        }
152
153        BindingProperty other= (BindingPropertyobj;
154        if (!Objects.equals(fParentother.fParent)) {
155            return false;
156        }
157
158        if (!Objects.equals(fNameother.fName)) {
159            return false;
160        }
161
162        return true;
163    }
164
165    /*
166     * @see java.lang.Object#hashCode()
167     */
168    @Override
169    public int hashCode() {
170        return (fParent != null ? fParent.hashCode() : 0)
171                + (fName != null ? fName.hashCode() : 0);
172    }
173}
174
MembersX
BindingProperty:createBindings
BindingProperty:fIsRelevant
BindingProperty:getLabel
BindingProperty:isRelevant
BindingProperty:fParent
BindingProperty:getParent
BindingProperty:createBindings:Block:res
BindingProperty:equals
BindingProperty:equals:Block:other
BindingProperty:getImage
BindingProperty:hashCode
BindingProperty:fName
BindingProperty:BindingProperty
BindingProperty:toString
BindingProperty:fValues
BindingProperty:getChildren
Members
X