1 package fr.ove.openmath.jome.ctrl.amto;
2
3 import fr.ove.openmath.jome.ctrl.linear.events.LinearParserEvent;
4 import fr.ove.openmath.jome.ctrl.amto.AbstractMathTreeObject;
5
6 /***
7 * The abstract math tree object of a n-ary operator.
8 *
9 * @author © 1999 DIRAT Laurent
10 * @version 1.0 18/11/1999
11 */
12 public abstract class MapsToNAry extends AbstractMathTreeObject {
13 /***
14 * The constructor.
15 * @param identifier the identifier of the instance.
16 * @param token the identifier of the instance by the mean of the event sent.
17 */
18 public MapsToNAry(String identifier, int token) {
19 super(identifier, token);
20 }
21
22 /***
23 * "Flushes" the object as a sequence of events for the building of the model
24 */
25 public void flush() {
26 LinearParserEvent linearParserEvent = new LinearParserEvent(getEventSource());
27
28 int nbChildren = getNbChildren();
29 if (nbChildren == 0) {
30 linearParserEvent.setToken(token, param);
31 fireLinearParserEvent(linearParserEvent);
32 }
33 else {
34 for (int i = 0; i < nbChildren; i++) {
35 flushChild(getChild(i), i);
36 if (i < (nbChildren - 1)) {
37 linearParserEvent.setToken(token, param);
38 fireLinearParserEvent(linearParserEvent);
39 }
40 }
41 }
42 }
43 }