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 operators which have "classical" MathML format :<BR>
38 * <apply><BR>
39 * <an operator/><BR>
40 * ... lots of other things ...<BR>
41 * </apply><BR>
42 *
43 * @author © 2000 DIRAT Laurent
44 * @version 1.0 23/05/2000
45 */
46 public class ClassicalOperatorFormater implements Formater {
47 /***
48 * Returns the specified object formatted as a string.
49 * @param formatedObject the formatted object (for structured object, could represents the beginning).
50 * @param formaterRepository where the different other formaters are.
51 * @param obj the object to format.
52 */
53 public String format(String formatedObject, FormaterRepository formaterRepository, Object obj) {
54 PMathMLFormater mmlFormater = (PMathMLFormater) formaterRepository;
55 FormulaTreeStructure fts = (FormulaTreeStructure) obj;
56
57 FormulaTreeStructure ftsChild;
58 Formater formater;
59
60 String symbolId = fts.getResourceIdentifier();
61
62 formatedObject += mmlFormater.writeStartGroup();
63
64
65 int nbChildren = fts.getNbChildren();
66 int nops = nbChildren-1;
67 for (int i = 0; i < nbChildren; i++) {
68
69 ftsChild = (FormulaTreeStructure) ((FormulaTreeStructure) obj).getChild(i);
70 String objectId = ftsChild.getResourceIdentifier();
71 formater = formaterRepository.getFormater(objectId);
72 formatedObject = formater.format(formatedObject, formaterRepository, ftsChild);
73 if( i != nops)
74 formatedObject += mmlFormater.writeSymbol(symbolId, fts.getCrossRef());
75
76 }
77 formatedObject += mmlFormater.writeEndGroup();
78
79 return formatedObject;
80 }
81 }