Class Node
- java.lang.Object
-
- org.datanucleus.store.query.compiler.Node
-
- Direct Known Subclasses:
ParameterNode
public class Node extends java.lang.ObjectRepresentation of a node in a tree of nodes. Has a parent, and a list of children. Each node has a type and a value. Optionally has a set of properties; these represent arguments when part of a method call.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<Node>childNodesList of child nodes in the tree below here.private intcursorPosWorking variable used for iterating between child nodes.protected NodeTypenodeTypeType of node.protected java.lang.ObjectnodeValueValue of the node.protected NodeparentParent of this node.private java.util.List<Node>propertiesList of properties for the node.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddProperty(Node node)NodeappendChildNode(Node node)Nodeclone(Node parent)NodegetChildNode(int index)java.util.List<Node>getChildNodes()NodegetFirstChild()Access the first child node.NodegetNextChild()Access the next node.java.lang.StringgetNodeChildId()java.lang.StringgetNodeId()NodeTypegetNodeType()java.lang.ObjectgetNodeValue()java.lang.StringgetNodeValueAsString()NodegetParent()java.util.List<Node>getProperties()booleanhasNextChild()Return whether there is a "next" child node.booleanhasProperties()private java.lang.Stringindent(int indentation)Utility to add on indenting when printing out the node tree.NodeinsertChildNode(Node node)NodeinsertChildNode(Node node, int position)private java.lang.StringprintTree(int indentation)Utility method to print out the node tree.voidremoveChildNode(Node node)voidsetNodeValue(java.lang.Object val)voidsetParent(Node parent)voidsetPropertyAtPosition(int position, Node node)java.lang.StringtoString()Method to print out the Node as a tree.
-
-
-
Field Detail
-
nodeType
protected NodeType nodeType
Type of node.
-
nodeValue
protected java.lang.Object nodeValue
Value of the node.
-
cursorPos
private int cursorPos
Working variable used for iterating between child nodes.
-
parent
protected Node parent
Parent of this node.
-
childNodes
protected java.util.List<Node> childNodes
List of child nodes in the tree below here.
-
properties
private java.util.List<Node> properties
List of properties for the node. Used for invocation of methods, representing the arguments.
-
-
Method Detail
-
getNodeType
public NodeType getNodeType()
-
setNodeValue
public void setNodeValue(java.lang.Object val)
-
getNodeValue
public java.lang.Object getNodeValue()
-
getNodeValueAsString
public java.lang.String getNodeValueAsString()
-
hasProperties
public boolean hasProperties()
-
getProperties
public java.util.List<Node> getProperties()
-
addProperty
public void addProperty(Node node)
-
setPropertyAtPosition
public void setPropertyAtPosition(int position, Node node)
-
getChildNodes
public java.util.List<Node> getChildNodes()
-
removeChildNode
public void removeChildNode(Node node)
-
getChildNode
public Node getChildNode(int index)
-
getFirstChild
public Node getFirstChild()
Access the first child node.- Returns:
- The first node, or null if no children present
-
getNextChild
public Node getNextChild()
Access the next node. This asssumes that the methodgetFirstChild
has been called before.- Returns:
- The next child
-
hasNextChild
public boolean hasNextChild()
Return whether there is a "next" child node. Assumes that the methodgetFirstChild
has been called before.- Returns:
- Whether there is a next child node.
-
setParent
public void setParent(Node parent)
-
getParent
public Node getParent()
-
getNodeId
public java.lang.String getNodeId()
-
getNodeChildId
public java.lang.String getNodeChildId()
-
toString
public java.lang.String toString()
Method to print out the Node as a tree.- Overrides:
toStringin classjava.lang.Object- Returns:
- the node tree as a string
-
printTree
private java.lang.String printTree(int indentation)
Utility method to print out the node tree.- Parameters:
indentation- What indent to use- Returns:
- The tree string
-
indent
private java.lang.String indent(int indentation)
Utility to add on indenting when printing out the node tree.- Parameters:
indentation- The indent size (number of spaces)- Returns:
- value indented
-
-