Package com.singularsys.jep.parser
Interface Node
-
- All Known Implementing Classes:
ASTConstant
,ASTFunNode
,ASTOpNode
,ASTStart
,ASTVarNode
,ControlNode
,IfNode
,LoopNode
,SequenceNode
,SimpleNode
,StructureNode
public interface Node
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
Node.HookKey
Nodes can optional have hooks which add meta-data to the node.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.Iterator<Node>
childIterator()
Returns an Iterator which iterates over the children of the Node.java.lang.Iterable<Node>
children()
Returns an Iterable object which can be used in a for/in loop.java.lang.Object
getHook(Node.HookKey key)
Get the object associated with the keyint
getId()
java.lang.String
getName()
Return the name associated with the node (if any).Operator
getOperator()
Return the operator associated with a Node (if any)PostfixMathCommandI
getPFMC()
Return the pfmc of a node (if any)java.lang.Object
getValue()
Return the value associated with the node (if any).Variable
getVar()
Return the variable associated with a Node (if any)java.util.Collection<Node.HookKey>
hookKeys()
Get all the keys defined for this node.java.lang.Object
jjtAccept(ParserVisitor visitor, java.lang.Object data)
Accept the visitor.void
jjtAddChild(Node n, int i)
This method tells the node to add its argument to the node's list of children.void
jjtClose()
This method is called after all the child nodes have been added.Node
jjtGetChild(int i)
This method returns a child node.int
jjtGetNumChildren()
Return the number of children the node has.Node
jjtGetParent()
void
jjtOpen()
This method is called after the node has been made the current node.void
jjtSetParent(Node n)
This pair of methods are used to inform the node of its parent.java.lang.Object
removeHook(Node.HookKey key)
Remove the keyjava.lang.Object
setHook(Node.HookKey key, java.lang.Object data)
Set the data associated with a given key
-
-
-
Method Detail
-
jjtOpen
void jjtOpen()
This method is called after the node has been made the current node. It indicates that child nodes can now be added to it.
-
jjtClose
void jjtClose()
This method is called after all the child nodes have been added.
-
jjtSetParent
void jjtSetParent(Node n)
This pair of methods are used to inform the node of its parent.
-
jjtGetParent
Node jjtGetParent()
-
jjtAddChild
void jjtAddChild(Node n, int i)
This method tells the node to add its argument to the node's list of children.
-
jjtGetChild
Node jjtGetChild(int i)
This method returns a child node. The children are numbered from zero, left to right.
-
jjtGetNumChildren
int jjtGetNumChildren()
Return the number of children the node has.- Returns:
- the number of child nodes
-
jjtAccept
java.lang.Object jjtAccept(ParserVisitor visitor, java.lang.Object data) throws JepException
Accept the visitor.- Throws:
JepException
-
getValue
java.lang.Object getValue()
Return the value associated with the node (if any).- Returns:
- the value if an ASTConstant, ASTVarNode, null otherwise
-
getName
java.lang.String getName()
Return the name associated with the node (if any).- Returns:
- the name if an ASTVarNode, ASTFunNode, ASTOpNode, null otherwise
-
getPFMC
PostfixMathCommandI getPFMC()
Return the pfmc of a node (if any)- Returns:
- the PostfixMathCommand for ASTFunNode and ASTOpNode, null otherwise
-
getOperator
Operator getOperator()
Return the operator associated with a Node (if any)- Returns:
- The Operator for ASTOpNodes, null otherwise
-
getVar
Variable getVar()
Return the variable associated with a Node (if any)- Returns:
- The Variable for ASTVarNodes, null otherwise
-
children
java.lang.Iterable<Node> children()
Returns an Iterable object which can be used in a for/in loop.for(Node child:node.children()) { ... }
-
childIterator
java.util.Iterator<Node> childIterator()
Returns an Iterator which iterates over the children of the Node. The remove method is unsupported.- Returns:
- a new Iterator
-
getId
int getId()
-
setHook
java.lang.Object setHook(Node.HookKey key, java.lang.Object data)
Set the data associated with a given key- Parameters:
key
- defining the type of datadata
- actual object- Returns:
- previous object associated with the key
-
getHook
java.lang.Object getHook(Node.HookKey key)
Get the object associated with the key- Parameters:
key
-- Returns:
- the object associated with the key
-
hookKeys
java.util.Collection<Node.HookKey> hookKeys()
Get all the keys defined for this node.- Returns:
- all the keys
-
removeHook
java.lang.Object removeHook(Node.HookKey key)
Remove the key- Parameters:
key
-- Returns:
- the object which was associated with the key
-
-