1 /*
2 $Id: VariableOrNumberFormater.java 709 2005-03-21 16:30:05Z guest $
3 */
4
5
6 /*
7 Copyright (C) 2001-2002 Mainline Project (I3S - ESSI - CNRS -UNSA)
8
9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Lesser General Public
11 License as published by the Free Software Foundation; either
12 version 2.1 of the License, or (at your option) any later version.
13
14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public
20 License along with this library; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
23 For further information on the GNU Lesser General Public License,
24 see: http://www.gnu.org/copyleft/lesser.html
25 For further information on this library, contact: mainline@essi.fr
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 float element.
38 *
39 * @author © 2000 DIRAT Laurent
40 * @version 1.0 07/01/2000
41 */
42 public class VariableOrNumberFormater implements Formater {
43 /***
44 * Returns the specified object formatted as a string.
45 * @param formatedObject the formatted object (for structured object, could represents the beginning).
46 * @param formaterRepository where the different other formaters are.
47 * @param obj the object to format.
48 */
49 public String format(String formatedObject, FormaterRepository formaterRepository, Object obj) {
50 VariableOrNumber fts = (VariableOrNumber) obj;
51 if (!fts.isTemplate()) {
52 PMathMLFormater mmlFormater = (PMathMLFormater) formaterRepository;
53 if (fts.isNumber()) {
54 //if (!fts.isInteger())
55 // formatedObject += mmlFormater.writeFloat(fts.getValue());
56 //else
57 formatedObject += mmlFormater.writeInteger(fts.getValue());
58 }
59 else
60 formatedObject += mmlFormater.writeIdentifier(fts.getValue(), fts.getCrossRef());
61 }
62
63 return formatedObject;
64 }
65 }