派生自 projectDept/qhighschool

yn147
2023-05-10 96286178ee1c257c130cb2ad964a781f36c4eee5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
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();    
    
}