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.mml.*;
34
35 /***
36 * Formats the formula tree structure as its corresponding MathML object.<BR>
37 * This is the formater of the formula root, so returns the formatted representation of the child of
38 * the instance, enclosed by the <OMOBJ></OMOBJ> pair of tags.
39 *
40 * @author © 2000 DIRAT Laurent
41 * @version 1.0 07/01/2000
42 */
43 public class FormulaFormater implements Formater {
44 /***
45 * Returns the specified object formatted as a string.
46 * @param formatedObject the formatted object (for structured object, could represents the beginning).
47 * @param formaterRepository where the different other formaters are.
48 * @param obj the object to format.
49 */
50 public String format(String formatedObject, FormaterRepository formaterRepository, Object obj) {
51 if (((FormulaTreeStructure) obj).getNbChildren() != 0) {
52 PMathMLFormater mmlFormater = (PMathMLFormater) formaterRepository;
53 mmlFormater.initIndent();
54 formatedObject += mmlFormater.writeStartObject();
55
56 FormulaTreeStructure ftsChild = (FormulaTreeStructure)((FormulaTreeStructure) obj).getChild(0);
57 String objectId = ftsChild.getResourceIdentifier();
58 Formater formater = mmlFormater.getFormater(objectId);
59 formatedObject = formater.format(formatedObject, mmlFormater, ftsChild);
60
61 formatedObject += mmlFormater.writeEndObject();
62 }
63 return formatedObject;
64 }
65 }