com.github.tsijercic1.Node Maven / Gradle / Ivy
package com.github.tsijercic1;
import java.util.*;
public class Node {
private String name;
private String content;
private Map attributes;
private ArrayList childNodes;
public Node() {
attributes = new TreeMap<>();
childNodes = new ArrayList<>();
}
public Node(String name) {
this();
this.name = name;
}
public void setName(String name) {
this.name=name;
}
public String getName() {
return name;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public void addAttribute(String key, String value) {
attributes.put(key, value);
}
public void addChildNode(Node node) {
childNodes.add(node);
}
public Map getAttributes() {
return attributes;
}
public ArrayList getChildNodes() {
return childNodes;
}
public ArrayList getChildNodes(String name){
ArrayList nodes = new ArrayList<>(childNodes);
nodes.removeIf(node -> !node.getName().equals(name));
return nodes;
}
public Set getAttributeKeys(){
return attributes.keySet();
}
public Collection getAttributeValues(){
return attributes.values();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy