Revision 44154 trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/src/main/java/org/gvsig/expressionevaluator/impl/DefaultCodeBuilder.java
DefaultCodeBuilder.java | ||
---|---|---|
113 | 113 |
|
114 | 114 |
} |
115 | 115 |
|
116 |
public class BaseIdentifier extends BaseCode implements Identifier { |
|
116 |
public interface RecursionControlSupport { |
|
117 |
|
|
118 |
public boolean enterCode(int max); |
|
119 |
|
|
120 |
public void exitCode(); |
|
121 |
|
|
122 |
public void resetRecursionState(); |
|
123 |
} |
|
124 |
|
|
125 |
private class RecursionSupport implements RecursionControlSupport { |
|
126 |
|
|
127 |
private int counter; |
|
128 |
|
|
129 |
public RecursionSupport() { |
|
130 |
this.counter = 0; |
|
131 |
} |
|
117 | 132 |
|
118 |
String name; |
|
133 |
@Override |
|
134 |
public boolean enterCode(int max) { |
|
135 |
this.counter += 1; |
|
136 |
return this.counter < max; |
|
137 |
} |
|
119 | 138 |
|
139 |
@Override |
|
140 |
public void exitCode() { |
|
141 |
this.counter -= 1; |
|
142 |
} |
|
143 |
|
|
144 |
@Override |
|
145 |
public void resetRecursionState() { |
|
146 |
this.counter = 0; |
|
147 |
} |
|
148 |
|
|
149 |
} |
|
150 |
|
|
151 |
public class BaseIdentifier extends BaseCode implements Identifier, RecursionControlSupport { |
|
152 |
|
|
153 |
private String name; |
|
154 |
private RecursionSupport recursionSupport; |
|
155 |
|
|
120 | 156 |
public BaseIdentifier(String name) { |
121 | 157 |
this.name = name; |
158 |
this.recursionSupport = new RecursionSupport(); |
|
122 | 159 |
} |
123 | 160 |
|
124 | 161 |
@Override |
... | ... | |
140 | 177 |
return builder.toString(); |
141 | 178 |
} |
142 | 179 |
|
180 |
@Override |
|
181 |
public boolean enterCode(int max) { |
|
182 |
return this.recursionSupport.enterCode(max); |
|
183 |
} |
|
184 |
|
|
185 |
@Override |
|
186 |
public void exitCode() { |
|
187 |
this.recursionSupport.exitCode(); |
|
188 |
} |
|
189 |
|
|
190 |
@Override |
|
191 |
public void resetRecursionState() { |
|
192 |
this.recursionSupport.resetRecursionState(); |
|
193 |
} |
|
194 |
|
|
143 | 195 |
} |
144 | 196 |
|
145 | 197 |
public class BaseCodes implements Codes { |
... | ... | |
212 | 264 |
|
213 | 265 |
} |
214 | 266 |
|
215 |
public class BaseCaller extends BaseCode implements Caller { |
|
267 |
public class BaseCaller extends BaseCode implements Caller, RecursionControlSupport {
|
|
216 | 268 |
|
217 | 269 |
private final String name; |
218 | 270 |
private final Codes args; |
219 | 271 |
private Function function; |
220 | 272 |
private final int type; |
273 |
private RecursionSupport recursionSupport; |
|
221 | 274 |
|
222 | 275 |
public BaseCaller(String name, int type, Codes args) { |
223 | 276 |
this.name = name; |
224 | 277 |
this.args = args; |
225 | 278 |
this.type = type; |
226 | 279 |
this.function = null; |
280 |
this.recursionSupport = new RecursionSupport(); |
|
227 | 281 |
} |
228 | 282 |
|
229 | 283 |
@Override |
... | ... | |
282 | 336 |
return builder.toString(); |
283 | 337 |
} |
284 | 338 |
|
339 |
@Override |
|
340 |
public boolean enterCode(int max) { |
|
341 |
return this.recursionSupport.enterCode(max); |
|
342 |
} |
|
343 |
|
|
344 |
@Override |
|
345 |
public void exitCode() { |
|
346 |
this.recursionSupport.exitCode(); |
|
347 |
} |
|
348 |
|
|
349 |
@Override |
|
350 |
public void resetRecursionState() { |
|
351 |
this.recursionSupport.resetRecursionState(); |
|
352 |
} |
|
285 | 353 |
} |
286 | 354 |
|
287 | 355 |
public class BaseMethod extends BaseCaller implements Method { |
Also available in: Unified diff