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.Function;
5
6 /***
7 * The abstract math tree object of the partial differentiation.
8 *
9 * @author © 2000 DIRAT Laurent
10 * @version 1.0 23/02/2000
11 */
12 public class PartialDifferentiation extends Function {
13 /***
14 * The constructor.
15 */
16 public PartialDifferentiation() {
17 super("pdiff");
18 }
19
20 /***
21 * "Flushes" the object as a sequence of events for the building of the model
22 */
23 public void flush() {
24 LinearParserEvent linearParserEvent = new LinearParserEvent(getEventSource());
25
26
27
28
29
30 linearParserEvent.setToken(opening, param);
31 fireLinearParserEvent(linearParserEvent);
32
33
34 AbstractMathTreeObject list = (AbstractMathTreeObject) getChild(0);
35 AbstractMathTreeObject lambda = (AbstractMathTreeObject) getChild(1);
36
37
38 int nbChildren = lambda.getNbChildren();
39 int count = nbChildren - 1;
40 flushChild(lambda.getChild(count), count);
41
42
43 nbChildren = list.getNbChildren();
44 AnInteger listElement;
45 int listElementValue;
46 for (int i = 0; i < nbChildren; i++) {
47 listElement = (AnInteger) list.getChild(i);
48
49 try {
50 listElementValue = Integer.parseInt((String) listElement.param);
51 if ((listElementValue > 0) && (listElementValue <= count)) {
52 linearParserEvent.setToken(token, null);
53 fireLinearParserEvent(linearParserEvent);
54 flushChild(lambda.getChild(listElementValue-1), i);
55 }
56 }
57 catch (NumberFormatException nfe) {
58 nfe.printStackTrace();
59 }
60 }
61
62
63 linearParserEvent.setToken(closing, null);
64 fireLinearParserEvent(linearParserEvent);
65 }
66 }