EclipseJDT ASTViewer Source Viewer

Home|eclipse_jdt_astviewer/src/org/eclipse/jdt/astview/views/GeneralAttribute.java
1/*******************************************************************************
2 * Copyright (c) 2000, 2006 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 *******************************************************************************/
14
15package org.eclipse.jdt.astview.views;
16
17import java.util.Objects;
18
19import org.eclipse.swt.graphics.Image;
20
21
22public class GeneralAttribute extends ASTAttribute {
23
24    private final Object fParent;
25    private final String fLabel;
26    private final Object[] fChildren;
27
28    public GeneralAttribute(Object parentString nameObject value) {
29        fParentparent;
30        fLabelname + ": " + String.valueOf(value);
31        fChildrenEMPTY;
32    }
33
34    public GeneralAttribute(Object parentString label) {
35        fParentparent;
36        fLabellabel;
37        fChildrenEMPTY;
38    }
39
40    public GeneralAttribute(Object parentString nameObject[] children) {
41        fParentparent;
42        if (children == null) {
43            fLabelname + ": null";
44            fChildrenEMPTY;
45        } else if (children.length == 0) {
46            fLabelname + " (0)";
47            fChildrenEMPTY;
48        } else {
49            fChildrencreateChildren(children);
50            fLabelname + " (" + String.valueOf(fChildren.length) + ')';
51        }
52    }
53
54    private Object[] createChildren(Object[] children) {
55        ASTAttribute[] res= new ASTAttribute[children.length];
56        for (int i0i < res.lengthi++) {
57            Object childchildren[i];
58            String nameString.valueOf(i);
59            res[i]= Binding.createValueAttribute(this, namechild);
60        }
61        return res;
62    }
63
64    @Override
65    public Object getParent() {
66        return fParent;
67    }
68
69    @Override
70    public Object[] getChildren() {
71        return fChildren;
72    }
73
74    @Override
75    public String getLabel() {
76        return fLabel;
77    }
78
79    @Override
80    public Image getImage() {
81        return null;
82    }
83
84    /*
85     * @see java.lang.Object#equals(java.lang.Object)
86     */
87    @Override
88    public boolean equals(Object obj) {
89        if (this == obj)
90            return true;
91        if (obj == null || !obj.getClass().equals(getClass())) {
92            return false;
93        }
94
95        GeneralAttribute other= (GeneralAttributeobj;
96        if (!Objects.equals(fParentother.fParent)) {
97            return false;
98        }
99
100        if (!Objects.equals(fLabelother.fLabel)) {
101            return false;
102        }
103
104        return true;
105    }
106
107    /*
108     * @see java.lang.Object#hashCode()
109     */
110    @Override
111    public int hashCode() {
112        return (fParent != null ? fParent.hashCode() : 0)
113                + (fLabel != null ? fLabel.hashCode() : 0);
114    }
115}
116
MembersX
GeneralAttribute:fChildren
GeneralAttribute:fParent
GeneralAttribute:fLabel
GeneralAttribute:createChildren
GeneralAttribute:getParent
GeneralAttribute:GeneralAttribute
GeneralAttribute:createChildren:Block:Block:child
GeneralAttribute:createChildren:Block:res
GeneralAttribute:getChildren
GeneralAttribute:getImage
GeneralAttribute:getLabel
GeneralAttribute:createChildren:Block:Block:name
GeneralAttribute:hashCode
GeneralAttribute:equals
GeneralAttribute:equals:Block:other
Members
X