View Javadoc

1   package fr.ove.openmath.jome.model;
2   
3   import java.util.*;
4   import fr.ove.openmath.jome.model.*;
5   
6   /***
7   * This class represents the kind of child K-ary will have.
8   *
9   * @author © 1999 DIRAT Laurent
10  * @version 1.0  24/02/1999
11  */
12  public final class Slot extends FormulaTreeStructure {
13      // Y a de fortes chances pour qu'on ne surclasse jamais Slot.
14      
15      FormulaTreeStructure nextSlot;
16      
17      /***
18      * The Constructor.
19      * 
20      */
21      public Slot() {
22          setResourceIdentifier("SLOT");
23          setAsOperatorPriority(resourcesManager.getAsOperatorPriority("slotPriorities"));
24          setAsOperandPriority(resourcesManager.getAsOperandPriority("slotPriorities"));
25      }
26      
27      public FormulaTreeStructure getNextSlot() {
28          return nextSlot;
29      }
30      
31      public void setNextSlot(FormulaTreeStructure nextSlot) {
32          this.nextSlot = nextSlot;
33      }
34      
35      // En fait, vu l'usage, toutes les mÈthodes des ÈlÈments de la fts ne servent pas.
36      // Seules les valeurs de l'instance vue comme opÈrateur ou comme opÈrande sont utiles
37      // pour la construction de la fts.
38  
39      // ObligÈ ici de surcharger cette mÈthode pour palier les cas pathologiques de, je suis 
40      // dÈj? sur une instance de Slot (exemple, on a une fonction comme fils a un slot, le goto
41      // correpondant ? la fermeture de la parenthËse de la fonction, nous a mis comme position
42      // courante d'insertion, le slot. Si en suivant, on met un sÈparateur (donc on veut ajouter
43      // un autre slot) il faut que l'on reste sur l'instance. A priori on ne va jamais aller plus
44      // haut dans la fts qu'un slot en passant par un goTo. Donc si cette mÈthode est appelÈe, c'est
45      // que la position courante d'insertion est l'instance, donc on ne fait rien, la position
46      // courante d'insertion reste la mÍme.
47      public FormulaTreeStructure goTo(int priority) {
48          return this;
49      }
50  
51      
52      /*** 
53      * Inserts the icon (node) in the formula tree structure.<BR>
54      * @param current the position in the formula tree where the operator is to be insert.
55      * @return the new current position int hte formula tree.
56      */
57      public FormulaTreeStructure insert(FormulaTreeStructure current) {
58          // On s'en fout.
59          return null;
60      }
61      
62      /***
63      * The Creation of the corresponding linear expression of the formula.
64      */
65      public String createLinear(String linear) {
66          return ((FormulaTreeStructure) getChild(0)).createLinear("");
67      }
68     
69      /***
70      * Evaluates the instance.
71      */
72      public String evaluate() {
73          return ((FormulaTreeStructure) getChild(0)).evaluate();
74      }
75      
76      /***
77      * To check is the instance is an operator.
78      * @return <CODE>true</CODE> if it is an operator. <CODE>false</CODE> otherwise.
79      */
80      public boolean isOperator() {
81          return false;
82      }
83      
84      // *****************************************
85      // ImplÈmentation de l'interface Iconifiable
86      
87      /***
88      * Returns the name of the icon associated to the instance.
89      *
90      * @returns The name of the icon, or <CODE>null</CODE> if there is no name
91      * associated.
92      */
93      public String getIconName() {
94          return ((FormulaTreeStructure) getChild(0)).getIconName();
95      }
96  
97      // *** Fin de l'interface Iconifiable ***
98      // **************************************
99      
100     // *****************************************
101     // ImplÈmentation de l'interface Modifiable
102     
103     /***
104     * Sets the value.
105     */
106     public void setValue(String value) {
107     }
108     
109     /***
110     * Returns the value.
111     */
112     public String getValue() {
113         return null;
114     }
115     
116     // *** Fin de l'interface Modifiable ***
117     // *************************************
118 }