1 package fr.ove.openmath.jome.formaters.mml;
2
3 import fr.ove.utils.*;
4 import fr.ove.openmath.jome.model.*;
5 import fr.ove.openmath.jome.formaters.mml.*;
6
7 /***
8 * Formats the formula tree structure as its corresponding MathML object.<BR>
9 * This is the formater of the formula root, so returns the formatted representation of the child of
10 * the instance, enclosed by the <OMOBJ></OMOBJ> pair of tags.
11 *
12 * @author © 2000 DIRAT Laurent
13 * @version 1.0 07/01/2000
14 */
15 public class FormulaFormater implements Formater {
16 /***
17 * Returns the specified object formatted as a string.
18 * @param formatedObject the formatted object (for structured object, could represents the beginning).
19 * @param formaterRepository where the different other formaters are.
20 * @param obj the object to format.
21 */
22 public String format(String formatedObject, FormaterRepository formaterRepository, Object obj) {
23 if (((FormulaTreeStructure) obj).getNbChildren() != 0) {
24 MathMLFormater mmlFormater = (MathMLFormater) formaterRepository;
25 mmlFormater.initIndent();
26 formatedObject += mmlFormater.writeStartObject();
27
28 FormulaTreeStructure ftsChild = (FormulaTreeStructure)((FormulaTreeStructure) obj).getChild(0);
29 String objectId = ftsChild.getResourceIdentifier();
30 Formater formater = mmlFormater.getFormater(objectId);
31 formatedObject = formater.format(formatedObject, mmlFormater, ftsChild);
32
33 formatedObject += mmlFormater.writeEndObject();
34 }
35 return formatedObject;
36 }
37 }