|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.singularsys.jep.NodeFactory
public class NodeFactory
This class is used to create nodes of specified types. It can be sub-classed to change the nature of how nodes are constructed. Generally there are two methods for creating nodes, methods which take an existing node and methods which take the components.
Field Summary | |
---|---|
protected Evaluator |
ev
|
protected Jep |
j
|
protected VariableTable |
vt
|
Constructor Summary | |
---|---|
NodeFactory()
|
Method Summary | |
---|---|
ASTConstant |
buildConstantNode(ASTConstant node)
Create an ASTConstant with same value as argument |
ASTConstant |
buildConstantNode(java.lang.Object value)
Creates an ASTConstant node with specified value. |
ASTConstant |
buildConstantNode(Operator op,
Node child1)
Creates a ASTConstant whose value of applying a unary operator to its arguments. |
ASTConstant |
buildConstantNode(Operator op,
Node[] children)
Creates a ASTConstant whose value of applying the operator to its arguments. |
ASTConstant |
buildConstantNode(Operator op,
Node child1,
Node child2)
Creates a ASTConstant whose value of applying binary operator to its arguments. |
ASTConstant |
buildConstantNode(PostfixMathCommandI pfmc,
Node[] children)
Creates a constant node whose result is the given function applied to the children. |
ASTFunNode |
buildFunctionNode(ASTFunNode node,
Node[] arguments)
Builds a function with n arguments and same fun as specified in arguments. |
ASTFunNode |
buildFunctionNode(java.lang.String name,
PostfixMathCommandI pfmc,
Node[] arguments)
Builds a function with n arguments This method should be sub-classed |
ASTOpNode |
buildOperatorNode(Operator op,
Node child)
creates a unary function. |
ASTOpNode |
buildOperatorNode(Operator op,
Node[] arguments)
Builds a operator node with n arguments This method should be sub-classed |
ASTOpNode |
buildOperatorNode(Operator op,
Node lhs,
Node rhs)
creates a binary function. |
ASTOpNode |
buildUnfinishedOperatorNode(Operator op)
An unfinished node. |
ASTVarNode |
buildVariableNode(ASTVarNode node)
creates a new ASTVarNode with the same name as argument. |
ASTVarNode |
buildVariableNode(java.lang.String name)
Build a variable node when just the name is known. |
ASTVarNode |
buildVariableNode(Variable var)
creates a new ASTVarNode with a given variable. |
ASTVarNode |
buildVariableNodeCheckUndeclared(java.lang.String name)
Build a variable node checking for the undeclared status. |
void |
copyChildren(Node node,
Node[] children)
Sets the children of node to be those specified in array. |
JepComponent |
getLightWeightInstance()
Gets a light-weight instance suitable for using in multiple threads. |
void |
init(Jep jep)
Initialize the component. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected transient Evaluator ev
protected transient VariableTable vt
protected transient Jep j
Constructor Detail |
---|
public NodeFactory()
Method Detail |
---|
public void init(Jep jep)
JepComponent
init
in interface JepComponent
jep
- the current Jep instancepublic void copyChildren(Node node, Node[] children)
node
- the node whose children will be set.children
- an array of nodes which will be the children of the node.public ASTConstant buildConstantNode(java.lang.Object value) throws ParseException
ParseException
public ASTConstant buildConstantNode(ASTConstant node) throws ParseException
ParseException
public ASTConstant buildConstantNode(PostfixMathCommandI pfmc, Node[] children) throws ParseException
pfmc
- the function to applychildren
- the arguments to the function, each argument should be a constant node.
ParseException
public ASTConstant buildConstantNode(Operator op, Node[] children) throws ParseException
ParseException
public ASTConstant buildConstantNode(Operator op, Node child1, Node child2) throws ParseException
ParseException
public ASTConstant buildConstantNode(Operator op, Node child1) throws ParseException
ParseException
public ASTVarNode buildVariableNode(ASTVarNode node) throws ParseException
ParseException
public ASTVarNode buildVariableNode(Variable var) throws ParseException
ParseException
public ASTVarNode buildVariableNode(java.lang.String name) throws ParseException
name
- the name of the variable
ParseException
public ASTVarNode buildVariableNodeCheckUndeclared(java.lang.String name) throws ParseException
name
- name of the variable
ParseException
- if undeclared variables are not allowed and the variable does not existpublic ASTOpNode buildOperatorNode(Operator op, Node[] arguments) throws ParseException
op
- the operator to usearguments
- the arguments to the function.
ParseException
public ASTFunNode buildFunctionNode(java.lang.String name, PostfixMathCommandI pfmc, Node[] arguments) throws ParseException
name
- of function.pfmc
- PostfixMathCommand for function.arguments
- the arguments to the function.
ParseException
public ASTOpNode buildUnfinishedOperatorNode(Operator op)
public ASTOpNode buildOperatorNode(Operator op, Node child) throws ParseException
ParseException
public ASTOpNode buildOperatorNode(Operator op, Node lhs, Node rhs) throws ParseException
ParseException
public ASTFunNode buildFunctionNode(ASTFunNode node, Node[] arguments) throws ParseException
node
- the properties (name and pfmc) of this node will be copied.arguments
- the arguments to the function.
ParseException
public JepComponent getLightWeightInstance()
JepComponent
getLightWeightInstance
in interface JepComponent
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |