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 org.util.activemath.JomeConstants;
32
33 import fr.ove.utils.*;
34 import fr.ove.openmath.jome.model.*;
35 import fr.ove.openmath.jome.formaters.mml.*;
36
37 /***
38 * Formats the formula tree structure as its corresponding MathML object.<BR>
39 * This is the formater of the float element.
40 *
41 * @author © 2000 DIRAT Laurent
42 * @version 1.0 07/01/2000
43 */
44 public class SymbolFormater implements Formater {
45 /***
46 * Returns the specified object formatted as a string.
47 * @param formatedObject the formatted object (for structured object, could represents the beginning).
48 * @param formaterRepository where the different other formaters are.
49 * @param obj the object to format.
50 */
51 public String format(String formatedObject, FormaterRepository formaterRepository, Object obj) {
52
53 FormulaTreeStructure fts = (FormulaTreeStructure) obj;
54
55 PMathMLFormater mmlFormater = (PMathMLFormater) formaterRepository;
56
57 String value = fts.getValue();
58
59 if(value.length() == 0)
60 return formatedObject;
61
62 String symbolName = mmlFormater.resourcesManager.getElementName(value);
63
64 if(symbolName != null)
65 value = symbolName;
66 else{
67
68 JomeConstants.Symbol symbol = (JomeConstants.Symbol)JomeConstants.SYMBOLS.get(value);
69
70 if(symbol != null){
71 value = symbol.getUniCode();
72 }
73 }
74
75 formatedObject += mmlFormater.writeSymbolName(value, fts.getCrossRef());
76
77 return formatedObject;
78 }
79 }