import java.util.ArrayList;
public class Node {
public Node parent = null;
public ArrayList childrenList = new ArrayList();
public String value;
boolean isRoot = false;
public Node() {
}
public Node(String value) {
this.value = value;
}
public void addChild(Node child) {
childrenList.add(child);
}
public Node getChild(int index) {
return childrenList.get(index);
}
public int getChildCount() {
return childrenList.size();
}
public int getDepth() {
if (isRoot())
return 0;
else
return 1 + getParent().getDepth();
}
public boolean isInternalNode() {
if (childrenList != null)
return true;
else
return false;
}
public boolean isLeaf() {
if (childrenList == null)
return true;
else
return false;
}
public boolean isRoot() {
return isRoot;
}
public void removeChildAt(int index) {
childrenList.remove(index);
}
public void setRoot() {
isRoot = true;
}
public Node getParent() {
return parent;
}
public void setParent(Node parent) {
this.parent = parent;
}
public ArrayList getChildrenList() {
return childrenList;
}
}