KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > nfunk > jep > Operator


1 /* @author rich
2  * Created on 03-Aug-2003
3  *
4  * This code is covered by a Creative Commons
5  * Attribution, Non Commercial, Share Alike license
6  * <a HREF="http://creativecommons.org/licenses/by-nc-sa/1.0">License</a>
7  */

8 package org.nfunk.jep;
9
10 import org.nfunk.jep.function.PostfixMathCommandI;
11
12 /**
13  * A class containing information about an operator.
14  *
15  * @see OperatorSet
16  * @author Rich Morris
17  * Created on 19-Oct-2003
18  */

19 public class Operator {
20
21     /** A unique name defining the operator. */
22     private String JavaDoc name;
23     /** The symbol for the operator, used for printing. */
24     private String JavaDoc symbol;
25     /** Postfix mathcommand */
26     private PostfixMathCommandI pfmc;
27     
28     /** private default constructor, prevents calling with no arguments. */
29     private Operator()
30     {
31     }
32
33     /** construct a new operator.
34      *
35      * @param name printable name of operator
36      * @param pfmc postfix math command for opperator
37      */

38     public Operator(String JavaDoc name,PostfixMathCommandI pfmc)
39     {
40         this();
41         this.name = name; this.pfmc = pfmc;
42         this.symbol = name;
43     }
44     /** construct a new operator, with a different name and symbol
45      *
46      * @param name name of operator, must be unique, used when describing operator
47      * @param symbol printable name of operator, used for printing equations
48      * @param pfmc postfix math command for opperator
49      */

50     public Operator(String JavaDoc name,String JavaDoc symbol,PostfixMathCommandI pfmc)
51     {
52         this();
53         this.name = name; this.pfmc = pfmc;
54         this.symbol = symbol;
55     }
56     /** returns the symbol used by this operator. */
57     public final String JavaDoc getSymbol() {return symbol;}
58     /** returns a unique name definig this operator. */
59     public final String JavaDoc getName() {return name;}
60     public final PostfixMathCommandI getPFMC() { return pfmc;}
61     public final void setPFMC(PostfixMathCommandI pfmc) { this.pfmc = pfmc;}
62     /** returns a verbose representation of the operator. **/
63     public String JavaDoc toString() { return "Operator: \""+name+"\""; }
64 }
65
Popular Tags