]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.spreadsheet.common/src/org/simantics/spreadsheet/common/expression/node/APlusExpression.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.spreadsheet.common / src / org / simantics / spreadsheet / common / expression / node / APlusExpression.java
1 /*******************************************************************************\r
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
3  * in Industry THTH ry.\r
4  * All rights reserved. This program and the accompanying materials\r
5  * are made available under the terms of the Eclipse Public License v1.0\r
6  * which accompanies this distribution, and is available at\r
7  * http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 /* This file was generated by SableCC (http://www.sablecc.org/). */\r
13 \r
14 package org.simantics.spreadsheet.common.expression.node;\r
15 \r
16 import org.simantics.spreadsheet.common.expression.analysis.*;\r
17 \r
18 @SuppressWarnings("nls")\r
19 public final class APlusExpression extends PExpression\r
20 {\r
21     private PExpression _left_;\r
22     private TPlus _plus_;\r
23     private PMultiplicative _right_;\r
24 \r
25     public APlusExpression()\r
26     {\r
27         // Constructor\r
28     }\r
29 \r
30     public APlusExpression(\r
31         @SuppressWarnings("hiding") PExpression _left_,\r
32         @SuppressWarnings("hiding") TPlus _plus_,\r
33         @SuppressWarnings("hiding") PMultiplicative _right_)\r
34     {\r
35         // Constructor\r
36         setLeft(_left_);\r
37 \r
38         setPlus(_plus_);\r
39 \r
40         setRight(_right_);\r
41 \r
42     }\r
43 \r
44     @Override\r
45     public Object clone()\r
46     {\r
47         return new APlusExpression(\r
48             cloneNode(this._left_),\r
49             cloneNode(this._plus_),\r
50             cloneNode(this._right_));\r
51     }\r
52 \r
53     public void apply(Switch sw)\r
54     {\r
55         ((Analysis) sw).caseAPlusExpression(this);\r
56     }\r
57 \r
58     public PExpression getLeft()\r
59     {\r
60         return this._left_;\r
61     }\r
62 \r
63     public void setLeft(PExpression node)\r
64     {\r
65         if(this._left_ != null)\r
66         {\r
67             this._left_.parent(null);\r
68         }\r
69 \r
70         if(node != null)\r
71         {\r
72             if(node.parent() != null)\r
73             {\r
74                 node.parent().removeChild(node);\r
75             }\r
76 \r
77             node.parent(this);\r
78         }\r
79 \r
80         this._left_ = node;\r
81     }\r
82 \r
83     public TPlus getPlus()\r
84     {\r
85         return this._plus_;\r
86     }\r
87 \r
88     public void setPlus(TPlus node)\r
89     {\r
90         if(this._plus_ != null)\r
91         {\r
92             this._plus_.parent(null);\r
93         }\r
94 \r
95         if(node != null)\r
96         {\r
97             if(node.parent() != null)\r
98             {\r
99                 node.parent().removeChild(node);\r
100             }\r
101 \r
102             node.parent(this);\r
103         }\r
104 \r
105         this._plus_ = node;\r
106     }\r
107 \r
108     public PMultiplicative getRight()\r
109     {\r
110         return this._right_;\r
111     }\r
112 \r
113     public void setRight(PMultiplicative node)\r
114     {\r
115         if(this._right_ != null)\r
116         {\r
117             this._right_.parent(null);\r
118         }\r
119 \r
120         if(node != null)\r
121         {\r
122             if(node.parent() != null)\r
123             {\r
124                 node.parent().removeChild(node);\r
125             }\r
126 \r
127             node.parent(this);\r
128         }\r
129 \r
130         this._right_ = node;\r
131     }\r
132 \r
133     @Override\r
134     public String toString()\r
135     {\r
136         return ""\r
137             + toString(this._left_)\r
138             + toString(this._plus_)\r
139             + toString(this._right_);\r
140     }\r
141 \r
142     @Override\r
143     void removeChild(@SuppressWarnings("unused") Node child)\r
144     {\r
145         // Remove child\r
146         if(this._left_ == child)\r
147         {\r
148             this._left_ = null;\r
149             return;\r
150         }\r
151 \r
152         if(this._plus_ == child)\r
153         {\r
154             this._plus_ = null;\r
155             return;\r
156         }\r
157 \r
158         if(this._right_ == child)\r
159         {\r
160             this._right_ = null;\r
161             return;\r
162         }\r
163 \r
164         throw new RuntimeException("Not a child.");\r
165     }\r
166 \r
167     @Override\r
168     void replaceChild(@SuppressWarnings("unused") Node oldChild, @SuppressWarnings("unused") Node newChild)\r
169     {\r
170         // Replace child\r
171         if(this._left_ == oldChild)\r
172         {\r
173             setLeft((PExpression) newChild);\r
174             return;\r
175         }\r
176 \r
177         if(this._plus_ == oldChild)\r
178         {\r
179             setPlus((TPlus) newChild);\r
180             return;\r
181         }\r
182 \r
183         if(this._right_ == oldChild)\r
184         {\r
185             setRight((PMultiplicative) newChild);\r
186             return;\r
187         }\r
188 \r
189         throw new RuntimeException("Not a child.");\r
190     }\r
191 }\r