|
1 |
| package edu.rice.cs.javalanglevels.tree; |
|
2 |
| |
|
3 |
| import edu.rice.cs.javalanglevels.SourceInfo; |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| public class VariableDeclaration extends JExpression implements BodyItemI, ForInitI { |
|
11 |
| private final ModifiersAndVisibility _mav; |
|
12 |
| private final VariableDeclarator[] _declarators; |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
265
| public VariableDeclaration(SourceInfo in_sourceInfo, ModifiersAndVisibility in_mav, VariableDeclarator[] in_declarators) {
|
|
19 |
265
| super(in_sourceInfo);
|
|
20 |
| |
|
21 |
265
| if (in_mav == null) {
|
|
22 |
0
| throw new java.lang.IllegalArgumentException("Parameter 'mav' to the VariableDeclaration constructor was null. This class may not have null field values.");
|
|
23 |
| } |
|
24 |
265
| _mav = in_mav;
|
|
25 |
| |
|
26 |
265
| if (in_declarators == null) {
|
|
27 |
0
| throw new java.lang.IllegalArgumentException("Parameter 'declarators' to the VariableDeclaration constructor was null. This class may not have null field values.");
|
|
28 |
| } |
|
29 |
265
| _declarators = in_declarators;
|
|
30 |
| } |
|
31 |
| |
|
32 |
709
| final public ModifiersAndVisibility getMav() { return _mav; }
|
|
33 |
1413
| final public VariableDeclarator[] getDeclarators() { return _declarators; }
|
|
34 |
| |
|
35 |
364
| public <RetType> RetType visit(JExpressionIFVisitor<RetType> visitor) { return visitor.forVariableDeclaration(this); }
|
|
36 |
0
| public void visit(JExpressionIFVisitor_void visitor) { visitor.forVariableDeclaration(this); }
|
|
37 |
| |
|
38 |
| |
|
39 |
| |
|
40 |
| |
|
41 |
| |
|
42 |
1
| public java.lang.String toString() {
|
|
43 |
1
| java.io.StringWriter w = new java.io.StringWriter();
|
|
44 |
1
| output(w);
|
|
45 |
1
| return w.toString();
|
|
46 |
| } |
|
47 |
| |
|
48 |
| |
|
49 |
| |
|
50 |
| |
|
51 |
1
| public void output(java.io.Writer writer) {
|
|
52 |
1
| outputHelp(new TabPrintWriter(writer, 2));
|
|
53 |
| } |
|
54 |
| |
|
55 |
101
| public void outputHelp(TabPrintWriter writer) {
|
|
56 |
101
| writer.print("VariableDeclaration" + ":");
|
|
57 |
101
| writer.indent();
|
|
58 |
| |
|
59 |
101
| writer.startLine("");
|
|
60 |
101
| writer.print("sourceInfo = ");
|
|
61 |
101
| SourceInfo temp_sourceInfo = getSourceInfo();
|
|
62 |
101
| if (temp_sourceInfo == null) {
|
|
63 |
0
| writer.print("null");
|
|
64 |
| } else { |
|
65 |
101
| writer.print(temp_sourceInfo);
|
|
66 |
| } |
|
67 |
| |
|
68 |
101
| writer.startLine("");
|
|
69 |
101
| writer.print("mav = ");
|
|
70 |
101
| ModifiersAndVisibility temp_mav = getMav();
|
|
71 |
101
| if (temp_mav == null) {
|
|
72 |
0
| writer.print("null");
|
|
73 |
| } else { |
|
74 |
101
| temp_mav.outputHelp(writer);
|
|
75 |
| } |
|
76 |
| |
|
77 |
101
| writer.startLine("");
|
|
78 |
101
| writer.print("declarators = ");
|
|
79 |
101
| writer.print("{");
|
|
80 |
101
| writer.indent();
|
|
81 |
101
| for (int i = 0; i < getDeclarators().length; i++) {
|
|
82 |
109
| VariableDeclarator temp_declarators = getDeclarators()[i];
|
|
83 |
109
| writer.startLine("#" + i + ": ");
|
|
84 |
109
| if (temp_declarators == null) {
|
|
85 |
0
| writer.print("null");
|
|
86 |
| } else { |
|
87 |
109
| temp_declarators.outputHelp(writer);
|
|
88 |
| } |
|
89 |
| } |
|
90 |
101
| writer.unindent();
|
|
91 |
101
| if (getDeclarators().length > 0) {
|
|
92 |
101
| writer.startLine("");
|
|
93 |
| } |
|
94 |
101
| writer.print("}");
|
|
95 |
101
| writer.unindent();
|
|
96 |
| } |
|
97 |
| |
|
98 |
| |
|
99 |
| |
|
100 |
| |
|
101 |
| |
|
102 |
| |
|
103 |
1
| public boolean equals(java.lang.Object obj) {
|
|
104 |
0
| if (obj == null) return false;
|
|
105 |
1
| if ((obj.getClass() != this.getClass()) || (obj.hashCode() != this.hashCode())) {
|
|
106 |
1
| return false;
|
|
107 |
| } else { |
|
108 |
0
| VariableDeclaration casted = (VariableDeclaration) obj;
|
|
109 |
0
| if (! (getMav().equals(casted.getMav()))) return false;
|
|
110 |
0
| if (this.getDeclarators().length != casted.getDeclarators().length) return false;
|
|
111 |
0
| for (int i = 0; i < getDeclarators().length; i++) if (! getDeclarators()[i].equals(casted.getDeclarators()[i])) return false;
|
|
112 |
0
| return true;
|
|
113 |
| } |
|
114 |
| } |
|
115 |
| |
|
116 |
| |
|
117 |
| |
|
118 |
| |
|
119 |
| |
|
120 |
| |
|
121 |
| |
|
122 |
2
| protected int generateHashCode() {
|
|
123 |
2
| int code = getClass().hashCode();
|
|
124 |
2
| code ^= 0;
|
|
125 |
2
| code ^= getMav().hashCode();
|
|
126 |
3
| for (int i = 0; i < getDeclarators().length; i++) code ^= getDeclarators()[i].hashCode();
|
|
127 |
2
| return code;
|
|
128 |
| } |
|
129 |
| } |