KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*****************************************************************************
2
3 JEP - Java Math Expression Parser 2.3.0
4       October 3 2004
5       (c) Copyright 2004, Nathan Funk and Richard Morris
6       See LICENSE.txt for license information.
7
8 *****************************************************************************/

9 /* Generated By:JJTree: Do not edit this line. ASTFunNode.java */
10 package org.nfunk.jep;
11
12 import org.nfunk.jep.function.*;
13 // rjm unneeded import
14
// import java.util.*;
15

16 /**
17  * Function Node
18  */

19 public class ASTFunNode extends SimpleNode {
20     
21     /** The function class used to evaluate the node */
22     private PostfixMathCommandI pfmc;
23     
24     /** Name of the function */
25     private String JavaDoc name;
26     
27     /** ID of the operator (if it is one) */
28     private Operator opID=null;
29     
30     /**
31      * Creates a new ASTFunNode
32      */

33     public ASTFunNode(int id) {
34         super(id);
35     }
36     
37     /**
38      * Creates a new ASTFunNode
39      */

40     public ASTFunNode(Parser p, int id) {
41         super(p, id);
42     }
43     
44     /**
45      * Accept the visitor.
46      */

47     public Object JavaDoc jjtAccept(ParserVisitor visitor, Object JavaDoc data) throws ParseException
48     {
49         return visitor.visit(this, data);
50     }
51
52     /**
53      * Sets the function for a node. A name and function class must
54      * be specified.
55      */

56     public void setFunction(String JavaDoc name_in, PostfixMathCommandI pfmc_in) {
57         name = name_in;
58         pfmc = pfmc_in;
59     }
60     
61     /**
62      * Sets the opID, name and pfmc for this node by looking up the values
63      * in the Operators class
64      */

65     public void setOperator(Operator op) {
66             opID = op;
67             pfmc = op.getPFMC();
68             name = op.getName();
69     }
70
71     /**
72      * Returns a string containing the function name.
73      */

74     public String JavaDoc toString() {
75         return "Function \"" + name + "\"";
76     }
77
78     /**
79      * Returns the math command class associated with this node.
80      */

81     public PostfixMathCommandI getPFMC() {
82         return pfmc;
83     }
84     
85     /**
86      * Returns the name of the node (operator symbol or function name).
87      */

88     public String JavaDoc getName() {
89         return name;
90     }
91     
92     /**
93      * Returns the id number of the operator if the node is an operator.
94      */

95     public Operator getOperator() {
96         return opID;
97     }
98
99     /**
100      * Returns true if node is an operator.
101      */

102     public boolean isOperator() {
103         return (opID != null);
104     }
105 }
106
Popular Tags