1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 package fr.ove.openmath.jome.formaters.pmml;
30
31 import fr.ove.utils.*;
32 import fr.ove.openmath.jome.model.*;
33 import fr.ove.openmath.jome.formaters.pmml.PMathMLFormater;
34
35 /***
36 * Formats the formula tree structure as its corresponding OpenMath object.<BR>
37 * Format the function element.
38 *
39 * @author © 2000 DIRAT Laurent
40 * @version 1.0 07/01/2000
41 */
42 public class FunctionFormater2 implements Formater {
43 /***
44 * Returns the specified object formatted as a string.
45 * @param formatedObject the formatted object (for structured object, could represents the beginning).
46 * @param formaterRepository where the different other formaters are.
47 * @param obj the object to format.
48 */
49 public String format(String formatedObject, FormaterRepository formaterRepository, Object obj) {
50 PMathMLFormater mmlFormater = (PMathMLFormater) formaterRepository;
51 Function2 fts = (Function2) obj;
52
53 String objectId = fts.getTheOperator();
54 objectId = objectId.substring(0, objectId.length()-1);
55
56 Formater formater = null;
57 FormulaTreeStructure ftsChild = null;
58 int nbChildren = fts.getNbChildren();
59
60
61 formatedObject += mmlFormater.writeStartElement("mrow");
62
63 for (int i = 0; i < nbChildren; i++) {
64 ftsChild = (FormulaTreeStructure) fts.getChild(i).getChild(0);
65 objectId = ftsChild.getResourceIdentifier();
66 formater = formaterRepository.getFormater(objectId);
67 formatedObject = formater.format(formatedObject, formaterRepository, ftsChild);
68 }
69
70 formatedObject += mmlFormater.writeEndElement("mrow");
71
72 return formatedObject;
73 }}