org.lsmp.djep.xjep
Class NodeFactory

java.lang.Object
  extended by org.lsmp.djep.xjep.NodeFactory
Direct Known Subclasses:
MatrixNodeFactory

public class NodeFactory
extends java.lang.Object

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.

Author:
Rich Morris Created on 16-Nov-2003

Constructor Summary
NodeFactory(XJep xj)
           
 
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 ASTConstant whose value of applying the operator to its arguments.
 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
 ASTFunNode buildOperatorNode(Operator op, Node child)
          creates a unary function.
 ASTFunNode buildOperatorNode(Operator op, Node[] arguments)
          Builds a operator node with n arguments This method should be sub-classed
 ASTFunNode buildOperatorNode(Operator op, Node lhs, Node rhs)
          creates a binary function.
 ASTFunNode 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, java.lang.Object value)
           
 ASTVarNode buildVariableNode(Variable var)
          creates a new ASTVarNode with a given variable.
 void copyChildren(Node node, Node[] children)
          Sets the children of node to be those specified in array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NodeFactory

public NodeFactory(XJep xj)
Method Detail

copyChildren

public void copyChildren(Node node,
                         Node[] children)
Sets the children of node to be those specified in array.

Parameters:
node - the node whose children will be set.
children - an array of nodes which will be the children of the node.

buildConstantNode

public ASTConstant buildConstantNode(java.lang.Object value)
                              throws ParseException
Creates an ASTConstant node with specified value. This method should be overwritten by subclasses.

Throws:
ParseException

buildConstantNode

public ASTConstant buildConstantNode(ASTConstant node)
                              throws ParseException
Create an ASTConstant with same value as argument. *

Throws:
ParseException

buildConstantNode

public ASTConstant buildConstantNode(PostfixMathCommandI pfmc,
                                     Node[] children)
                              throws java.lang.IllegalArgumentException,
                                     ParseException
Creates a ASTConstant whose value of applying the operator to its arguments.

Throws:
java.lang.IllegalArgumentException
ParseException

buildConstantNode

public ASTConstant buildConstantNode(Operator op,
                                     Node[] children)
                              throws java.lang.IllegalArgumentException,
                                     ParseException
Creates a ASTConstant whose value of applying the operator to its arguments.

Throws:
java.lang.IllegalArgumentException
ParseException

buildConstantNode

public ASTConstant buildConstantNode(Operator op,
                                     Node child1,
                                     Node child2)
                              throws java.lang.IllegalArgumentException,
                                     ParseException
Creates a ASTConstant whose value of applying binary operator to its arguments.

Throws:
java.lang.IllegalArgumentException
ParseException

buildConstantNode

public ASTConstant buildConstantNode(Operator op,
                                     Node child1)
                              throws java.lang.IllegalArgumentException,
                                     ParseException
Creates a ASTConstant whose value of applying a unary operator to its arguments.

Throws:
java.lang.IllegalArgumentException
ParseException

buildVariableNode

public ASTVarNode buildVariableNode(ASTVarNode node)
                             throws ParseException
creates a new ASTVarNode with the same name as argument.

Throws:
ParseException

buildVariableNode

public ASTVarNode buildVariableNode(Variable var)
                             throws ParseException
creates a new ASTVarNode with a given variable. This method should be sub-classed

Throws:
ParseException

buildVariableNode

public ASTVarNode buildVariableNode(java.lang.String name,
                                    java.lang.Object value)
                             throws ParseException
Throws:
ParseException

buildOperatorNode

public ASTFunNode buildOperatorNode(Operator op,
                                    Node[] arguments)
                             throws ParseException
Builds a operator node with n arguments This method should be sub-classed

Parameters:
op - the operator to use
arguments - the arguments to the function.
Returns:
top Node of expression
Throws:
ParseException

buildFunctionNode

public ASTFunNode buildFunctionNode(java.lang.String name,
                                    PostfixMathCommandI pfmc,
                                    Node[] arguments)
                             throws ParseException
Builds a function with n arguments This method should be sub-classed

Parameters:
name - of function.
pfmc - PostfixMathCommand for function.
arguments - the arguments to the function.
Returns:
top Node of expression
Throws:
ParseException

buildUnfinishedOperatorNode

public ASTFunNode buildUnfinishedOperatorNode(Operator op)
An unfinished node. Caller has responsibility for filling in the children.


buildOperatorNode

public ASTFunNode buildOperatorNode(Operator op,
                                    Node child)
                             throws ParseException
creates a unary function.

Throws:
ParseException

buildOperatorNode

public ASTFunNode buildOperatorNode(Operator op,
                                    Node lhs,
                                    Node rhs)
                             throws ParseException
creates a binary function.

Throws:
ParseException

buildFunctionNode

public ASTFunNode buildFunctionNode(ASTFunNode node,
                                    Node[] arguments)
                             throws ParseException
Builds a function with n arguments and same fun as specified in arguments.

Parameters:
node - the properties (name and pfmc) of this node will be copied.
arguments - the arguments to the function.
Returns:
top Node of expression
Throws:
ParseException


http://www.singularsys.com/jep Copyright © 2007 Singular Systems