1 package fr.ove.openmath.jome.formaters.om;
2
3 import fr.ove.utils.*;
4 import fr.ove.openmath.jome.model.*;
5 import fr.ove.openmath.jome.formaters.om.*;
6
7 /***
8 * Formats the formula tree structure as its corresponding OpenMath object.<BR>
9 * This is the formater of the float element.
10 *
11 * @author © 2000 DIRAT Laurent
12 * @version 1.0 07/01/2000
13 */
14 public class VariableOrNumberFormater implements Formater {
15 /***
16 * Returns the specified object formatted as a string.
17 * @param formatedObject the formatted object (for structured object, could represents the beginning).
18 * @param formaterRepository where the different other formaters are.
19 * @param obj the object to format.
20 */
21 public String format(String formatedObject, FormaterRepository formaterRepository, Object obj) {
22 VariableOrNumber fts = (VariableOrNumber) obj;
23
24 if (!fts.isTemplate()) {
25 OpenMathFormater omFormater = (OpenMathFormater) formaterRepository;
26 if (fts.isNumber()) {
27 if (!fts.isInteger())
28 formatedObject += omFormater.writeFloat(fts.getValue());
29 else
30 formatedObject += omFormater.writeInteger(fts.getValue());
31 }
32 else if (fts.isRequestVariable()) {
33 formatedObject += omFormater.writeStartApplication();
34 formatedObject += omFormater.writeSymbol("mfd2", "request_variable");
35 formatedObject += omFormater.writeVariable(fts.getValue());
36 formatedObject += omFormater.writeEndApplication();
37 }
38 else
39 formatedObject += omFormater.writeVariable(fts.getValue());
40 }
41
42 return formatedObject;
43 }
44 }