1 package fr.ove.openmath.jome.model;
2
3 import java.util.*;
4 import fr.ove.openmath.jome.model.*;
5
6 /***
7 * @author © 2000 DIRAT Laurent
8 * @version 2.1 24/02/2000
9 */
10 public class UnaryPostfixedOperator extends Operator {
11 /***
12 * Inserts the operator instance in the formula tree, from the current insertion position.
13 * (checks the priorities and goes up in the tree if necessary).
14 *
15 * @param ope the current insertion position.
16 * @return the new insertion position.
17 */
18 public FormulaTreeStructure insert(FormulaTreeStructure current) {
19 VariableOrNumber template;
20
21
22 current = findLocation(current);
23
24
25 current.addChild(this);
26
27 if ((current.getFather() == null) && (current.getNbChildren() == 1))
28 addChild(new VariableOrNumber());
29 else {
30 FormulaTreeStructure fts = (FormulaTreeStructure) current.getChild(getRank() - 1);
31
32
33 addChild(fts);
34
35
36
37 current.removeChild(fts);
38 }
39
40 FormulaTreeStructure child = (FormulaTreeStructure) getChild(0);
41 if (child.getResourceIdentifier().equals("OPEN_PAREN"))
42 ((Bracket) child).setIsVisible(true);
43
44
45
46
47 return this;
48 }
49
50 /***
51 * The Creation of the corresponding linear expression of the formula.
52 */
53 public String createLinear(String linear) {
54 linear = ((FormulaTreeStructure) getChild(0)).createLinear(linear);
55 linear += getTheOperator();
56 return linear;
57 }
58
59 /***
60 * Evaluates the instance.
61 */
62 public String evaluate() {
63 return ((FormulaTreeStructure) getChild(0)).evaluate() + getTheOperator();
64 }
65 }
66