1 package fr.ove.openmath.jome.model;
2
3 import java.util.*;
4 import fr.ove.openmath.jome.model.*;
5 import fr.ove.openmath.jome.model.events.ModelEvent;
6
7 /***
8 * The elements of an Mfd2substitution object.<BR>
9 * It is an operator of arity 2.
10 * <P>
11 * In fact, this object _MUST_ be instanciate by the Mfd2Substitution object, and only by it.
12 * Independently of the Mfd2Substitution object, the instance doesn't make any sense.
13 *
14 * @author © 1999 DIRAT Laurent
15 * @version 2.0 27/10/1999
16 */
17 public class Mfd2SubstitutionElement extends KaryOperator {
18 private boolean gotoVariable = true;
19 private boolean addNewInstance = false;
20
21 /***
22 * The Constructor.
23 *
24 */
25 public Mfd2SubstitutionElement() {
26
27
28
29
30 setResourceIdentifier("substElem");
31 setTheOperator("");
32 setOperatorArity(2);
33 setEnding("");
34 }
35
36 /***
37 * Inserts the instance in the formula tree structure.<BR>
38 * @param current the position in the formula tree where the operator is to be insert.
39 * @return the new current position int hte formula tree.
40 */
41 public FormulaTreeStructure insert(FormulaTreeStructure current) {
42
43 current = super.insert(current);
44 super.addElement();
45 return current;
46 }
47
48 /***
49 * Adds a new element (template) to the end of the list.
50 * Returns the new element.
51 */
52 public FormulaTreeStructure addElement() {
53
54
55
56
57
58 if (gotoVariable) {
59 gotoVariable = false;
60 addNewInstance = true;
61 return (FormulaTreeStructure) getChild(1).getChild(0);
62 }
63 else if (addNewInstance) {
64
65
66 addNewInstance = false;
67 return ((Mfd2Substitution) getFather().getFather()).addElement();
68 }
69 else
70 return super.addElement();
71 }
72
73 /***
74 * The Creation of the corresponding OpenMath object.
75 *
76 * @param OM_Object the OpenMath object.
77 * @param start start point for writing the OpenMath syntax for good presentation/indentation.
78 * @param indent the size of the indentation.
79 * @return the corresponding OpenMath object.
80 *
81 public String createOpenMath(String OM_Object, String start, String indent) {
82 // En fait, l'instance ne sera instanciÈ que par Mfd2Substitution qui ? vraiment un correspondance
83 // avec un objet OM.
84 // Donc surcharge, puisque l'instance n'a pas de CD, et on retourne seulement les objets contenus
85 // succÈssivement.
86 OM_Object = ((FormulaTreeStructure) getChild(0)).createOpenMath(OM_Object, start+indent, indent);
87 OM_Object = ((FormulaTreeStructure) getChild(1)).createOpenMath(OM_Object, start+indent, indent);
88
89 return OM_Object;
90 }
91 */
92 }