package com.qxueyou.scc.exercise.service.impl;
|
|
import java.util.ArrayList;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
public abstract class Node {
|
|
private String name;
|
|
private Node parent;
|
|
private List<Node> children = new ArrayList<Node>(5);;
|
|
private Map<String,Object> attributes = new HashMap<String,Object>(5);;
|
|
private Parser parser;
|
|
public String getName() {
|
return name;
|
}
|
|
public void setName(String name) {
|
this.name = name;
|
}
|
|
public Node getParent() {
|
return parent;
|
}
|
|
public void setParent(Node parent) {
|
this.parent = parent;
|
}
|
|
public Parser getParser() {
|
return parser;
|
}
|
|
public void setParser(Parser parser) {
|
this.parser = parser;
|
}
|
|
public List<Node> getChildren() {
|
return children;
|
}
|
|
public Node getChild(String attributeName,Object attribute) {
|
for(Node node:children){
|
if(attribute.equals(node.getAttribute(attributeName))){
|
return node;
|
}
|
}
|
return null;
|
}
|
|
public void addNode(Node node){
|
node.setParent(this);
|
children.add(node);
|
}
|
|
public Map<String, Object> getAttributes() {
|
return attributes;
|
}
|
|
public Object getAttribute(String name) {
|
return attributes.get(name);
|
}
|
|
public void setAttribute(String name,Object value) {
|
attributes.put(name, value);
|
}
|
|
public abstract boolean isComplete();
|
|
}
|